hello.cpp

来自「一大堆的qt程序,在qte2.3.7下全部可以很好地运行」· C++ 代码 · 共 35 行

CPP
35
字号
#include <qapplication.h>#include <qlabel.h>#include <qbuttongroup.h>#include <qpushbutton.h>int main( int argc, char **argv){     int width=40,height=30,space=30;     QApplication app( argc, argv);     QButtonGroup box;     box.setGeometry(0,20,240,100);     QLabel label("hello,world!",0);//     QLabel *label = new QLabel("Hello,world!",0);     label.setAlignment(Qt::AlignVCenter |Qt:: AlignHCenter);     label.setGeometry(60,30,120,30);     label.hide();     QPushButton button1("h&ide",&box);     button1.setGeometry((240-5*space)/3+2*space,60,width,height);      QPushButton button0("&show",&box);     button0.setGeometry(space,60,width,height);     QPushButton button2("e&xit",&box);     button2.setGeometry((240-5*space)*2/3+3*space,60,width,height);     app.connect(&button0,SIGNAL(pressed()),&label,SLOT(show()));     app.connect(&button1,SIGNAL(clicked()),&label,SLOT(hide()));     app.connect(&button2,SIGNAL(released()),&app,SLOT(quit()));     app.setMainWidget(&box);     box.show();     return app.exec();} 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?