every component is a subclass of QWidget, QWidget is a subclass of QObject
every QObject has a parent pointer, indicating the ownership. A QWidget without
a parent is treated as a top-level window.
a layout object is used to manage the layout of its children widgets
QLabel *label = new QLabel(tr("Name:")); QLineEdit *lineEdit = new QLineEdit(); QHBoxLayout *layout = new QHBoxLayout(); layout->addWidget(label); layout->addWidget(lineEdit); window->setLayout(layout); |
similar to SWing’s panel, a layout object can also have children
QLabel *queryLabel = new QLabel(tr("Query:")); QLineEdit *queryEdit = new QLineEdit(); QTableView *resultView = new QTableView(); QHBoxLayout *queryLayout = new QHBoxLayout(); queryLayout->addWidget(queryLabel); queryLayout->addWidget(queryEdit); QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->addLayout(queryLayout); mainLayout->addWidget(resultView); window->setLayout(mainLayout); |
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.