skyilyskyily.blog.chinaunix.net
skyily
全部博文(144)
2010年(16)
2009年(128)
Zane_Yu
tasteswe
zwrvvv
xiao888l
zimuqing
leilelei
Phyllis6
jonathan
denghai1
wbdwbd04
itTangze
lifj1234
18141908
AAABug
分类: LINUX
2009-04-17 08:37:00
//.h文件
#include <QWidget>
class QString;
class QPushButton;class MyWidget:public QWidget{ Q_OBJECTpublic: MyWidget(QWidget *parent = 0);public slots: void setnum(); private: QPushButton *b1; int num; QString str;};
//.c文件
#include <QApplication>
#include #include
#include "main.h"void MyWidget::setnum(){ num++;// str = new QString; str.setNum(num); b1->setText(str);}MyWidget::MyWidget(QWidget *parent):QWidget(parent){ num = 0; b1 = new QPushButton(tr("0"), this);// b1 = new QPushButton(this); b1->setGeometry(10, 10, 100, 100); b1->setFont(QFont("Times", 16, QFont::Bold)); // str.setNum(num); connect(b1, SIGNAL(clicked()), this, SLOT(setnum()));}int main(int argc, char *argv[]){ QApplication app(argc, argv); MyWidget widget; widget.setGeometry(100, 100, 200, 200); widget.show(); return app.exec();}
编译:
在qt4下编译给其单独建立一个目录
$ qmake -project
$ qmake
$ make
$ ./15-4
上一篇:转义字符的完整诠释
下一篇:linux GNU shell中上下键翻历史的简单实现
登录 注册