//《24小时学通qt编程》 程序4-2
#include
#include
#include
#include
#include
#include
class MyMainWindow:public QWidget
{
public:
MyMainWindow();
private:
QPushButton *b1;
QPushButton *b2;
QPushButton *b3;
QLineEdit *ledit;
};
MyMainWindow::MyMainWindow()
{
//Orientation Vertical;
setGeometry(100,100,300,200);
b1=new QPushButton("Click here to mark the text",this);
b1->setGeometry(10,10,300,40);
b1->setFont(QFont("Times", 18, QFont::Bold));
b2=new QPushButton("Click here to unmark the text",this);
b2->setGeometry(10,60,300,40);
b2->setFont(QFont("Times", 18, QFont::Bold));
b3=new QPushButton("Click here to remove the text",this);
b3->setGeometry(10,110,300,40);
b3->setFont(QFont("Times", 18, QFont::Bold));
ledit=new QLineEdit("This is a Line of text",this);
ledit->setGeometry(10,160,300,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();
return 1;
}
阅读(1296) | 评论(0) | 转发(0) |