//find_dialog.cpp //practice QT layout //note: & means shortcut key #include<QApplication> #include<QLabel> #include<QPushButton> #include<QLineEdit> #include<QHBoxLayout> #include<QVBoxLayout> #include<QCheckBox> #include<QWidget> int main(int argc,char *argv[]) { QApplication app(argc,argv); QWidget* window=new QWidget; QLabel* label=new QLabel("Find &what"); QLineEdit* lineEdit=new QLineEdit; label->setBuddy(lineEdit); QHBoxLayout* lefttop=new QHBoxLayout; lefttop->addWidget(label); lefttop->addWidget(lineEdit); QCheckBox* caseCheckBox=new QCheckBox("match &case"); QCheckBox* backwardCheckBox=new QCheckBox("&backward"); QVBoxLayout* left=new QVBoxLayout; left->addLayout(lefttop); left->addWidget(caseCheckBox); left->addWidget(backwardCheckBox); QPushButton* find=new QPushButton("find"); QPushButton* cancel=new QPushButton("cancel"); QVBoxLayout* right=new QVBoxLayout; right->addWidget(find); right->addWidget(cancel); QHBoxLayout* main=new QHBoxLayout; main->addLayout(left); main->addLayout(right); QObject::connect(cancel,SIGNAL(clicked()),window,SLOT(close())); window->setLayout(main); window->setWindowTitle("find dialog"); window->show(); return app.exec(); }