#include<QApplication> #include<QLineEdit> #include<QPushButton> #include<QLabel> #include<QWidget> #include<QHBoxLayout> #include<QVBoxLayout> int main(int argc, char **argv) { QApplication app(argc,argv); QLabel *infoLable = new QLabel; QLabel *cmdLabel = new QLabel; QLineEdit *cmdLineEdit = new QLineEdit; QPushButton *submitButton =new QPushButton; QPushButton *cancelButton =new QPushButton; QPushButton *browserButton =new QPushButton; infoLable->setText("Plase input commad"); cmdLabel->setText("Open:"); cmdLineEdit->clear(); submitButton->setText("Submit"); cancelButton->setText("Cancel"); browserButton->setText("brower"); QHBoxLayout *cmdLayout =new QHBoxLayout; cmdLayout->addWidget(cmdLabel); cmdLayout->addWidget(cmdLineEdit); QHBoxLayout *buttonLayout =new QHBoxLayout; buttonLayout->addWidget(submitButton); buttonLayout->addWidget(cancelButton); buttonLayout->addWidget(browserButton); QVBoxLayout *mainLayout =new QVBoxLayout; mainLayout->addWidget(infoLable); mainLayout->addLayout(cmdLayout); mainLayout->addLayout(buttonLayout); QWidget *window =new QWidget; window->setLayout(mainLayout); window->setWindowTitle("Runing.."); window->show(); return app.exec(); return 0; }
原文:http://blog.csdn.net/billvsme/article/details/18301699