Skip to content

Instantly share code, notes, and snippets.

@Mandar-Shinde
Created December 1, 2015 14:28
Show Gist options
  • Save Mandar-Shinde/550ea0faf649dc64a4b9 to your computer and use it in GitHub Desktop.
Save Mandar-Shinde/550ea0faf649dc64a4b9 to your computer and use it in GitHub Desktop.
Qt Runtime GUI
// Main Widget
QWidget *mainAppWindow = new QWidget;
mainAppWindow->setWindowTitle("Runtime GUI");
mainAppWindow->setFixedSize(200, 300);
// Parent layout
QVBoxLayout *layoutParent= new QVBoxLayout();
// List of items
QListWidget *lv = new QListWidget();
lv->addItem("test1");
lv->addItem("test2");
lv->addItem("test3");
// Add listwidget to parent
layoutParent->addWidget(lv);
// Intermediate layout for button
QHBoxLayout *layoutButton = new QHBoxLayout;
// Buttons
QPushButton *bcan = new QPushButton();
bcan->setText("CANCEL");
QPushButton *bok = new QPushButton();
bok->setText("OK");
// Add button to intermediate layout (layoutButton)
layoutButton->addWidget(bcan);
layoutButton->addWidget(bok);
// Add to parent
layoutParent->addLayout(layoutButton);
// Set parent layout to window
mainAppWindow->setLayout(layoutParent);
// Display the window
mainAppWindow->show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment