📄 hello.cpp
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -