📄 test.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 tesxt",this); b1->setGeometry(10,10,280,40); b1->setFont(QFont("Times",18,QFont::Bold)); b2=new QPushButton("Click here to ummark the tesxt",this); b2->setGeometry(10,60,280,40); b2->setFont(QFont("Times",18,QFont::Bold)); b3=new QPushButton("Click here to remove the tesxt",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())); }int 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 + -