您的位置:首页 > 编程语言 > Qt开发

Qt -- button的使用

2015-10-06 14:46 411 查看
创建一个button部件,作为主窗口,点击该button退出窗体;

quit.cpp

//使用按键作为主窗口,带有退出功能
#include <QApplication>
#include <QPushButton>

int main(int argc,char *argv[])
{
QApplication app(argc,argv);                                   //创建QApplication对象app管理应用程序
QPushButton *button = new QPushButton("quit");                 //创建一个button部件
QObject::connect(button,SIGNAL(clicked()),&app,SLOT(quit()));  //创建一个连接,使button与app建立响应
button->show();                                                //显示button对象
return app.exec();    //进入循环主体
}


1.qmake -project --- 生成工程文件

2.qmake quit.pro ---生成一个makefile

3.make ---编译

4.debug\quit.exe --- 运行程序



F:\QT_Program\test01\quit>qmake -project

F:\QT_Program\test01\quit>qmake quit.pro

F:\QT_Program\test01\quit>make

mingw32-make -f Makefile.Debug

mingw32-make[1]: Entering directory `F:/QT_Program/test01/quit'

g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -

DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -

DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"d:\Qt\4.7

.3\include\QtCore" -I"d:\Qt\4.7.3\include\QtGui" -I"d:\Qt\4.7.3\include" -I"." -

I"d:\Qt\4.7.3\include\ActiveQt" -I"debug" -I"d:\Qt\4.7.3\mkspecs\win32-g++" -o d

ebug\quit.o quit.cpp

g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel

oc -mthreads -Wl -Wl,-subsystem,windows -o debug\quit.exe debug/quit.o -L"d:\Qt

\4.7.3\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4

mingw32-make[1]: Leaving directory `F:/QT_Program/test01/quit'

F:\QT_Program\test01\quit>debug\quit.exe

F:\QT_Program\test01\quit>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: