MainWindow::MainWindow() { QMenu *fileMenu = new QMenu(tr("&File")); QAction *quitAction = fileMenu->addAction(tr("E&xit")); quitAction->setShortcut(tr("Ctrl+Q")); QMenu *tableMenu = new QMenu(tr("&Table")); QAction *tableWidthAction = tableMenu->addAction(tr("Change Table &Width")); QAction *tableHeightAction = tableMenu->addAction(tr("Change Table &Height")); menuBar()->addMenu(fileMenu); menuBar()->addMenu(tableMenu); //! [0] tableWidget = new QTableWidget(this); //! [0] tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection); connect(quitAction, SIGNAL(triggered()), this, SLOT(close())); connect(tableWidthAction, SIGNAL(triggered()), this, SLOT(changeWidth())); connect(tableHeightAction, SIGNAL(triggered()), this, SLOT(changeHeight())); setupTableItems(); setCentralWidget(tableWidget); setWindowTitle(tr("Table Widget Resizing")); }
void StatesEditorWidget::reloadQmlSource() { QString statesListQmlFilePath = qmlSourcesPath() + QStringLiteral("/StatesList.qml"); QTC_ASSERT(QFileInfo::exists(statesListQmlFilePath), return); engine()->clearComponentCache(); setSource(QUrl::fromLocalFile(statesListQmlFilePath)); QTC_ASSERT(rootObject(), return); connect(rootObject(), SIGNAL(currentStateInternalIdChanged()), m_statesEditorView.data(), SLOT(synchonizeCurrentStateFromWidget())); connect(rootObject(), SIGNAL(createNewState()), m_statesEditorView.data(), SLOT(createNewState())); connect(rootObject(), SIGNAL(deleteState(int)), m_statesEditorView.data(), SLOT(removeState(int))); m_statesEditorView.data()->synchonizeCurrentStateFromWidget(); setFixedHeight(initialSize().height()); connect(rootObject(), SIGNAL(expandedChanged()), this, SLOT(changeHeight())); }