赞
踩
1。继承QWidget是要用public 。
2。构造函数也要是public。
3。构造函数的参数 初始化parent=0。
4。头文件声明了,源文件就要初始化。
- #include<QtGui/QtGui>
- class QLabel;
- class QLineEdit;
- class QPushButton;
- class QWidget;
-
- class InputDlg :public QWidget
- {
- Q_OBJECT
- public:
- InputDlg(QWidget *parent=0);
- ~InputDlg();
- public:
-
- QLabel *namelabel;
- QLabel *sexlabel;
- QLabel *agelabel;
- QLabel *heightlabel;
- QLineEdit *name;
- QLineEdit *sex;
- QLineEdit *age;
- QLineEdit *height;
- QPushButton *addname;
- QPushButton *addsex;
- QPushButton *addage;
- QPushButton *addheight;
-
- private slots:
- void slotName();
- void slotSex();
- void slotAge();
- void slotHeight();
- };

5。出现诸如下面的错误
- In file included from main.cpp:2:
- /usr/include/qt4/QtGui/qwidget.h: In copy constructor ‘InputDlg::InputDlg(const InputDlg&)’:
- /usr/include/qt4/QtGui/qwidget.h:782: error: ‘QWidget::QWidget(const QWidget&)’ is private
问题在于调用InputDlg声明的要是指针
InputDlg *dlg=new InputDlg;
6。
- button.h:10: error: invalid use of incomplete type ‘struct QPushButton’
- button.h:4: error: forward declaration of ‘struct QPushButton’
添加 #include <QtGui/QtGui>
问题解决了。。不过究竟是什么原因呢?
7。
数据库找不到头文件
在项目文件中加入
QT+=sql
8。
网络程序找不到头文件
在项目文件中加入
QT+=network
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。