⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 4_2.cpp

📁 一个qt设计的教程
💻 CPP
字号:
#include <qapplication.h>#include <qwidget.h>#include <qpushbutton.h>#include <qfont.h>#include <qlineedit.h>#include <qstring.h>class MyMainWindow:public QWidget{ public:    MyMainWindow(); private:    QPushButton *b1;    QPushButton *b2;    QPushButton *b3;    QLineEdit *ledit;};MyMainWindow::MyMainWindow(){ setGeometry(100,100,300,200);  b1 = new QPushButton("Click here to mark the text",this); b1->setGeometry(10,10,280,40); b1->setFont(QFont("Times",18,QFont::Bold)); b2 = new QPushButton("Click here to unmark the text",this); b2->setGeometry(10,60,280,40); b2->setFont(QFont("Times",18,QFont::Bold));  b3 = new QPushButton("Click here to remove the text",this); b3->setGeometry(10,110,280,40); b3->setFont(QFont("Times",18,QFont::Bold)); ledit = new QLineEdit("This is a line of text",this); ledit->setGeometry(10,160,280,30); connect(b1,SIGNAL(clicked()),ledit,SLOT(selectAll())); connect(b2,SIGNAL(clicked()),ledit,SLOT(deselect())); connect(b3,SIGNAL(clicked()),ledit,SLOT(clear()));}main(int argc,char **argv){ QApplication a(argc,argv); MyMainWindow w; a.setMainWidget(&w); w.show(); a.exec();}

⌨️ 快捷键说明

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