- /* addressbook.h*/
-
#include <QMainWindow>
-
#include <QLineEdit>
-
#include <QTextEdit>
-
-
class AddressBook :public QWidget
-
{
-
Q_OBJECT
-
-
public:
-
AddressBook(QWidget *parent = 0);
-
-
private:
-
QLineEdit *nameLine;
-
QTextEdit *addressText;
- };
- /* addressbook.cpp*/
-
#include <QtGui/QApplication>
-
#include <QLabel>
-
#include <QLineEdit>
-
#include <QTextEdit>
-
#include <QGridLayout>
-
-
AddressBook::AddressBook(QWidget *parent)
-
:QWidget(parent)
-
{
-
QLabel *nameLabel = new QLabel("Name: ");
-
nameLine = new QLineEdit;
-
-
QLabel *addressLabel = new QLabel("AdressBook: ");
-
addressText = new QTextEdit;
-
QGridLayout *mainLayout = new QGridLayout;
-
mainLayout->addWidget(nameLabel, 0, 0);
-
mainLayout->addWidget(nameLine, 0, 1);
-
mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
-
mainLayout->addWidget (addressText, 1, 1);
-
-
setLayout(mainLayout);
-
setWindowTitle ("Simple Address Book");
- }
- /*main.cpp*/
- #include "addressbook.h"
-
#include <QtGui/QApplication>
-
-
int main(int argc, char *argv[])
-
{
-
QApplication a(argc, argv);
-
-
AddressBook addressBook;
-
addressBook.show();
-
return a.exec();
- }
/*
今天仍然是“QT助手”的学习,仍然是对几个基本东西的了解,还是没有数据相关的操作,
这个地址本是有数据相关操作的,不过今天比较累,就学这么点吧。
今天主要学到的就是:addWidget(x,x,x);布局。。好像还蛮有用。。。
ps: 发现一个cublog的bug,就是在插入代码后, 想要退出代码编辑的框框不太容易,必须得进入“源代码”模式,
然后到最后一行,回车,才能跳出框框,不过在框框里写也不错,字体整洁好看还高亮....
*/