void CGraphicBuildingTile::display(QList<QString> _toDisplay) { QDialog* infoDialog = new QDialog;//(dynamic_cast<QWidget*>(this->parent())); QVBoxLayout* newLayout = new QVBoxLayout(); int q=0; QScrollArea* scrolArea = new QScrollArea(dynamic_cast<QWidget*>(this->parent())); for(int i=0;i<_toDisplay.count();i++) { QLabel* newLabel = new QLabel(_toDisplay.at(i)); newLabel->setFixedWidth(280); newLabel->setMinimumHeight(22); newLabel->setStyleSheet("border: 1px solid black"); newLayout->addWidget(newLabel); q++; } QPalette pal; pal.setColor(QPalette::Background,QColor(230,200,167)); infoDialog->setFixedWidth(330); infoDialog->setMinimumHeight(30+22*q); infoDialog->setLayout(newLayout); infoDialog->setAutoFillBackground(true); infoDialog->setPalette(pal); infoDialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::Dialog); scrolArea->setWidget(infoDialog); scrolArea->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::Dialog); scrolArea->setMaximumHeight(infoDialog->size().height()+2); scrolArea->setWindowTitle(QString("Info about")); scrolArea->show(); }
void CmdSrvDlg::showOptionsDlg() { QDialog dlg; dlg.setWindowFlags( dlg.windowFlags() & (~Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint) ); cmdUI = new Ui::CmdSrvDialog; cmdUI->setupUi( &dlg ); cmdUI->ipLE->setText( p.iface ); cmdUI->portSB->setValue( p.port ); cmdUI->toSB->setValue( p.timeout_ms ); cmdUI->enabledGB->setChecked( p.enabled ); ConnectUI( cmdUI->ipBut, SIGNAL(clicked()), this, SLOT(ipBut()) ); ConnectUI( cmdUI->buttonBox, SIGNAL(accepted()), this, SLOT(okBut()) ); if( QDialog::Accepted != dlg.exec() && !cmdServer ) { // If failed to set new listener...restore former. startServer(); } cmdUI->buttonBox->disconnect(); delete cmdUI; }
void AboutDialog::displayFile(const QString &fileName, const QString &title) { QDialog *dialog = new QDialog(this); QLayout *layout = new QVBoxLayout(dialog); QTextEdit *textEdit = new QTextEdit(dialog); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, dialog); textEdit->setStyleSheet(QLatin1String("font-family: monospace")); QFile file(fileName); if (file.open(QIODevice::ReadOnly)) { QString text = QTextStream(&file).readAll(); textEdit->setPlainText(text); } textEdit->setReadOnly(true); connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(close())); buttonBox->setCenterButtons(true); layout->addWidget(textEdit); layout->addWidget(buttonBox); layout->setMargin(6); dialog->setLayout(layout); dialog->setWindowTitle(title); dialog->setWindowFlags(Qt::Sheet); dialog->resize(600, 350); dialog->exec(); }
void Oubliette::showInventory() { QDialog *d = new QDialog(); d->setWindowTitle(tr("Inventory")); d->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); QGridLayout *gl = new QGridLayout(d); int row = 0; QLabel *label; const QList<const Item *> items = m_character.items(); if (items.isEmpty()) { label = new QLabel(tr("You have <B>No</B> Items"), d); label->setAlignment(Qt::AlignCenter); gl->addWidget(label, row, 0, 1, 4); ++row; } else { QListWidget *lw = new QListWidget(d); gl->addWidget(lw, 0, 0, 1, 4); int i = 0; foreach (const Item *item, items) { QListWidgetItem *lwi = new QListWidgetItem(item->name(), lw); lwi->setIcon(QIcon(item->pixmapName())); lwi->setData(99, i); ++i; } connect(lw, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(showInventoryItem(QListWidgetItem*))); }
bool DirtyListDescriber::showChanges(QWidget* aParent) { QDialog* dlg = new QDialog(aParent); Ui.setupUi(dlg); dlg->setWindowFlags(dlg->windowFlags() & ~Qt::WindowContextHelpButtonHint); theListWidget = Ui.ChangesList; runVisit(); CoordBox bbox = theDocument->getDirtyOrOriginLayer()->boundingBox(); QString bboxComment = QString("BBOX:%1,%2,%3,%4") .arg(QString::number(bbox.bottomLeft().x(), 'f', 2)) .arg(QString::number(bbox.bottomLeft().y(), 'f', 2)) .arg(QString::number(bbox.topRight().x(), 'f', 2)) .arg(QString::number(bbox.topRight().y(), 'f', 2)); QString statComment = QString("ADD:%1 UPD:%2 DEL:%3").arg(glbAdded).arg(glbUpdated).arg(glbDeleted); glbChangeSetComment = bboxComment + " " + statComment; Ui.edChangesetComment->setText(glbChangeSetComment); Ui.edChangesetComment->selectAll(); bool ok = (dlg->exec() == QDialog::Accepted); if (!Ui.edChangesetComment->text().isEmpty()) glbChangeSetComment = Ui.edChangesetComment->text(); else glbChangeSetComment = "-"; Task = Ui.ChangesList->count(); SAFE_DELETE(dlg) return ok; }
// Use for modeless or modal dialogs. // (Use show_widget instead, if displaying this widget NOT as a dialog.) // void MTDetailEdit::dialog(MTDetailEdit::DetailEditType theType, bool bIsModal/*=false*/) { FirstRun(theType); // This only does something the first time it's run. (Otherwise this does nothing.) // ------------------------------------------- RefreshRecords(); // ------------------------------------------- if (bIsModal) { QDialog theDlg; theDlg.setWindowTitle(this->windowTitle()); // theDlg.installEventFilter(this); QVBoxLayout * pLayout = new QVBoxLayout; pLayout->addWidget(this); theDlg.setLayout(pLayout); theDlg.setWindowFlags(Qt::Tool); // A hack so it will show the close button. theDlg.exec(); pLayout->removeWidget(this); } else { this->installEventFilter(this); show(); setFocus(); } // ------------------------------------------- }
DirectoryWebView* DirectoryWebView::createWindow(QWebEnginePage::WebWindowType type) { Q_UNUSED(type) QDialog *popup = new QDialog(this); QVBoxLayout *layout = new QVBoxLayout; DirectoryWebView *webview = new DirectoryWebView(this); layout->addWidget(webview); popup->setLayout(layout); popup->setWindowTitle(tr("ZIMA-CAD-Parts Technical Specifications")); popup->setWindowFlags(popup->windowFlags() | Qt::WindowMinMaxButtonsHint); popup->show(); return webview; }
QDialog *PluginManager::createAboutPluginDialog(QWidget *parent) { QDialog *rc = new QDialog(parent); rc->setWindowFlags(rc->windowFlags() & ~Qt::WindowContextHelpButtonHint & Qt::Sheet); rc->setWindowTitle(QCoreApplication::translate("QmlDesigner::PluginManager", "About Plugins")); QTreeView *treeView = new QTreeView; treeView->setModel(createModel(treeView)); treeView->expandAll(); QVBoxLayout *layout = new QVBoxLayout(rc); layout->addWidget(treeView); QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close); layout->addWidget(bb); QObject::connect(bb, SIGNAL(rejected()), rc, SLOT(reject())); return rc; }
void App::makeDialogWithString(const QString s) { QDialog *dialog = new QDialog(this); QLabel *label = new QLabel(this); QScrollArea *scroll = new QScrollArea(this); QVBoxLayout *layout = new QVBoxLayout(); dialog->setWindowFlags(dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint); label->setText(s); scroll->setWidget(label); scroll->setWidgetResizable(true); layout->addWidget(scroll); dialog->setLayout(layout); dialog->exec(); delete dialog; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setApplicationName(app.translate("main", "Browser Window")); #ifdef Q_WS_MAC app.setCursorFlashTime(0); #endif if (int error = enableNetworkProxying()) return error; QWebSettings *webSettings = QWebSettings::globalSettings(); webSettings->setAttribute(QWebSettings::AutoLoadImages, true); webSettings->setAttribute(QWebSettings::JavascriptEnabled, true); webSettings->setAttribute(QWebSettings::PluginsEnabled, true); #if QT_VERSION >= 0x040500 webSettings->setAttribute(QWebSettings::ZoomTextOnly, true); #endif #ifdef DEBUG webSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); #endif QString url("en.wikipedia.org/wiki/Main_Page"); if (argc > 1) url = argv[1]; QDialog dialog; BrowserWindow *browser = new BrowserWindow(url); if (argc > 2) browser->showToolBar(false); // For testing; don't quote QDialogButtonBox *buttonBox = new QDialogButtonBox; QPushButton *quitButton = buttonBox->addButton( app.translate("main", "&Quit"), QDialogButtonBox::AcceptRole); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(browser, 1); layout->addWidget(buttonBox); dialog.setLayout(layout); QObject::connect(quitButton, SIGNAL(clicked()), &dialog, SLOT(accept())); dialog.setWindowTitle(app.applicationName()); dialog.setWindowFlags(Qt::WindowSystemMenuHint); dialog.show(); return app.exec(); }
void MainWindow::on_actionYearlyStatistics_triggered() { QDialog d; QVBoxLayout *l = new QVBoxLayout(&d); YearlyStatisticsModel *m = new YearlyStatisticsModel(); QTreeView *view = new QTreeView(); view->setModel(m); l->addWidget(view); d.resize(width() * .8, height() / 2); d.move(width() * .1, height() / 4); QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), &d); connect(close, SIGNAL(activated()), &d, SLOT(close())); QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), &d); connect(quit, SIGNAL(activated()), this, SLOT(close())); d.setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::WindowTitleHint); d.setWindowTitle(tr("Yearly Statistics")); d.exec(); }
void FileViewManager::PreviewStandalone(const QString& filePathName, QWidget* dialogParent) { QDialog* fpdialog = new QDialog(dialogParent); fpdialog->setWindowTitle(QString("Preview '%1'").arg(QFileInfo(filePathName).fileName())); fpdialog->setContentsMargins(0, 0, 0, 0); fpdialog->resize(640, 480); //Maximize button would be more useful than a Help button on this dialog, e.g to view big pictures. Qt::WindowFlags flags = fpdialog->windowFlags(); flags &= ~Qt::WindowContextHelpButtonHint; flags |= Qt::WindowMaximizeButtonHint; fpdialog->setWindowFlags(flags); QHBoxLayout* hlay = new QHBoxLayout(fpdialog); hlay->setContentsMargins(0, 0, 0, 0); fpdialog->setLayout(hlay); FilePreviewerWidget* fpw = new FilePreviewerWidget(fpdialog); hlay->addWidget(fpw, 1); Preview(filePathName, fpw); fpdialog->exec(); }
void MTDetailEdit::dialog(MTDetailEdit::DetailEditType theType, bool bIsModal/*=false*/) { if (m_bFirstRun) { m_bFirstRun = false; // ------------------------------------------- ui->tableWidget->setColumnCount(2); ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); // ------------------------------------------- ui->tableWidget->horizontalHeader()->resizeSection(0, 5); // ------------------------------------------- ui->tableWidget->horizontalHeader()->setStretchLastSection(true); ui->tableWidget->verticalHeader()->setDefaultSectionSize(60); ui->tableWidget->verticalHeader()->hide(); ui->tableWidget->horizontalHeader()->hide(); // ------------------------------------------- ui->tableWidget->setContentsMargins(10,0,0,0); // ------------------------------------------- ui->tableWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding); // ---------------------------------- m_pTabWidget = new QTabWidget; // ---------------------------------- m_pTabWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_pTabWidget->setContentsMargins(5, 5, 5, 5); // ---------------------------------- QWidget * pTab1 = new QWidget; // ---------------------------------- pTab1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); pTab1->setContentsMargins(5, 5, 5, 5); // ---------------------------------- m_pTabWidget->addTab(pTab1, tr("Details")); // ------------------------------------------- // Instantiate m_pDetailPane to one of various types. // m_Type = theType; switch (m_Type) { case MTDetailEdit::DetailEditTypeNym: m_pDetailPane = new MTNymDetails(this, *this); break; case MTDetailEdit::DetailEditTypeContact: m_pDetailPane = new MTContactDetails(this, *this); break; case MTDetailEdit::DetailEditTypeServer: m_pDetailPane = new MTServerDetails(this, *this); break; case MTDetailEdit::DetailEditTypeAsset: m_pDetailPane = new MTAssetDetails(this, *this); break; case MTDetailEdit::DetailEditTypeAccount: m_pDetailPane = new MTAccountDetails(this, *this); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(DefaultAccountChanged(QString, QString)), m_pMoneychanger, SLOT (setDefaultAccount(QString, QString))); // ------------------------------------------- // connect(m_pDetailPane, SIGNAL(cashBalanceChanged()), // m_pMoneychanger, SLOT (onCashBalanceChanged())); // // ------------------------------------------- // connect(m_pDetailPane, SIGNAL(acctBalanceChanged()), // m_pMoneychanger, SLOT (onAcctBalanceChanged())); // // ------------------------------------------- break; default: qDebug() << "MTDetailEdit::dialog: MTDetailEdit::DetailEditTypeError"; return; } // ------------------------------------------- m_pDetailPane->SetOwnerPointer(*this); // ------------------------------------------- m_pDetailLayout = new QVBoxLayout; m_pDetailLayout->addWidget(m_pDetailPane); m_pDetailPane ->setContentsMargins(1,1,1,1); m_pDetailLayout->setContentsMargins(1,1,1,1); // ---------------------------------- pTab1->setLayout(m_pDetailLayout); // ---------------------------------- int nCustomTabCount = m_pDetailPane->GetCustomTabCount(); if (nCustomTabCount > 0) { for (int ii = 0; ii < nCustomTabCount; ii++) { QWidget * pTab = m_pDetailPane->CreateCustomTab(ii); // ---------------------------------- if (NULL != pTab) { pTab->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); pTab->setContentsMargins(5, 5, 5, 5); QString qstrTabName = m_pDetailPane->GetCustomTabName(ii); m_pTabWidget->addTab(pTab, qstrTabName); } // ---------------------------------- } } // ----------------------------------------------- QGridLayout * pGridLayout = new QGridLayout; pGridLayout->addWidget(m_pTabWidget); pGridLayout->setContentsMargins(0,0,0,0); m_pTabWidget->setTabPosition(QTabWidget::South); // ---------------------------------- ui->widget->setContentsMargins(1,1,1,1); // ---------------------------------- ui->widget->setLayout(pGridLayout); // ---------------------------------- } // first run. // ------------------------------------------- RefreshRecords(); // ------------------------------------------- // if (m_map.size() < 1) // on_addButton_clicked(); // ------------------------------------------- if (bIsModal) { QDialog theDlg; theDlg.setWindowTitle(this->windowTitle()); // theDlg.installEventFilter(this); QVBoxLayout * pLayout = new QVBoxLayout; pLayout->addWidget(this); theDlg.setLayout(pLayout); theDlg.setWindowFlags(Qt::Tool); // A hack so it will show the close button. theDlg.exec(); pLayout->removeWidget(this); } else { this->installEventFilter(this); show(); setFocus(); } // ------------------------------------------- }
QString AddImagesDialog::getDirectory(const QStringList &fileNames, const QString &defaultDirectory) { QDialog *dialog = new QDialog(Core::ICore::dialogParent()); dialog->setMinimumWidth(480); QString result; QString directory = defaultDirectory; dialog->setModal(true); dialog->setWindowFlags(dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint); dialog->setWindowTitle(QCoreApplication::translate("AddImageToResources","Add Resources")); QTableWidget *table = createFilesTable(fileNames); table->setParent(dialog); QGridLayout *mainLayout = new QGridLayout(dialog); mainLayout->addWidget(table, 0, 0, 1, 4); QComboBox *directoryComboBox = createDirectoryComboBox(defaultDirectory); auto setDirectoryForComboBox = [directoryComboBox, &directory](const QString &newDir) { if (directoryComboBox->findText(newDir) < 0) directoryComboBox->addItem(newDir); directoryComboBox->setCurrentText(newDir); directory = newDir; }; QObject::connect(directoryComboBox, &QComboBox::currentTextChanged, dialog, [&directory](const QString &text){ directory = text; }); QPushButton *browseButton = new QPushButton(QCoreApplication::translate("AddImageToResources", "&Browse..."), dialog); QObject::connect(browseButton, &QPushButton::clicked, dialog, [setDirectoryForComboBox, &directory]() { const QString newDir = QFileDialog::getExistingDirectory(Core::ICore::dialogParent(), QCoreApplication::translate("AddImageToResources", "Target Directory"), directory); if (!newDir.isEmpty()) setDirectoryForComboBox(newDir); }); mainLayout->addWidget(new QLabel(QCoreApplication::translate("AddImageToResources", "In directory:")), 1, 0); mainLayout->addWidget(directoryComboBox, 1, 0, 1, 3); mainLayout->addWidget(browseButton, 1, 3, 1 , 1); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); mainLayout->addWidget(buttonBox, 3, 2, 1, 2); QObject::connect(buttonBox, &QDialogButtonBox::accepted, dialog, [dialog](){ dialog->accept(); dialog->deleteLater(); }); QObject::connect(buttonBox, &QDialogButtonBox::rejected, dialog, [dialog, &directory](){ dialog->reject(); dialog->deleteLater(); directory = QString(); }); QObject::connect(dialog, &QDialog::accepted, [&directory, &result](){ result = directory; }); dialog->exec(); return result; }
QUndoCommand* PropertiesExtension::performAction(QAction *action, GLWidget *widget) { QUndoCommand *undo = 0; PropertiesModel *model; PropertiesView *view; QDialog *dialog = new QDialog(qobject_cast<QWidget *>(parent())); QVBoxLayout *layout = new QVBoxLayout(dialog); dialog->setLayout(layout); // Don't show whitespace around the PropertiesView layout->setSpacing(0); layout->setContentsMargins(0,0,0,0); int i = action->data().toInt(); switch (i) { case AtomPropIndex: // atom properties // model will be deleted in PropertiesView::hideEvent using deleteLater(). model = new PropertiesModel(PropertiesModel::AtomType); model->setMolecule(m_molecule); // view will delete itself in PropertiesView::hideEvent using deleteLater(). view = new PropertiesView(PropertiesView::AtomType, dialog); connect(m_molecule, SIGNAL( atomAdded(Atom*) ), model, SLOT( atomAdded(Atom*) )); connect(m_molecule, SIGNAL( atomRemoved(Atom*) ), model, SLOT( atomRemoved(Atom*) )); break; case BondPropIndex: // bond properties // model will be deleted in PropertiesView::hideEvent using deleteLater(). model = new PropertiesModel(PropertiesModel::BondType); model->setMolecule( m_molecule ); // view will delete itself in PropertiesView::hideEvent using deleteLater(). view = new PropertiesView(PropertiesView::BondType, widget); connect(m_molecule, SIGNAL( bondAdded(Bond*) ), model, SLOT( bondAdded(Bond*) )); connect(m_molecule, SIGNAL( bondRemoved(Bond*) ), model, SLOT( bondRemoved(Bond*) )); break; case AnglePropIndex: // angle properties // model will be deleted in PropertiesView::hideEvent using deleteLater(). model = new PropertiesModel(PropertiesModel::AngleType); model->setMolecule( m_molecule ); // view will delete itself in PropertiesView::hideEvent using deleteLater(). view = new PropertiesView(PropertiesView::AngleType, widget); break; case TorsionPropIndex: // torsion properties // model will be deleted in PropertiesView::hideEvent using deleteLater(). model = new PropertiesModel(PropertiesModel::TorsionType); model->setMolecule( m_molecule ); // view will delete itself in PropertiesView::hideEvent using deleteLater(). view = new PropertiesView(PropertiesView::TorsionType, widget); break; /*case CartesianIndex: // cartesian editor // m_angleModel will be deleted in PropertiesView::hideEvent using deleteLater(). model = new PropertiesModel(PropertiesModel::CartesianType); model->setMolecule( m_molecule ); // m_view will delete itself in PropertiesView::hideEvent using deleteLater(). view = new PropertiesView(PropertiesView::CartesianType, widget); connect(m_molecule, SIGNAL(atomAdded(Atom*)), model, SLOT( atomAdded(Atom*))); connect(m_molecule, SIGNAL(atomRemoved(Atom*)), model, SLOT(atomRemoved(Atom*))); break;*/ case ConformerIndex: // conformers // model will be deleted in PropertiesView::hideEvent using deleteLater(). model = new PropertiesModel(PropertiesModel::ConformerType, dialog); model->setMolecule( m_molecule ); // view will delete itself in PropertiesView::hideEvent using deleteLater(). view = new PropertiesView(PropertiesView::ConformerType, dialog); break; default: delete dialog; layout = 0; // deleted as a child of the dialog return 0; } connect(m_molecule, SIGNAL(moleculeChanged()), model, SLOT(moleculeChanged())); connect(m_molecule, SIGNAL( updated() ), model, SLOT( updateTable() )); QSortFilterProxyModel* proxyModel = new QSortFilterProxyModel(this); proxyModel->setSourceModel(model); proxyModel->setDynamicSortFilter(true); proxyModel->setSortLocaleAware(true); // this role will received direct floating-point numbers from the model proxyModel->setSortRole(Qt::UserRole); view->setMolecule( m_molecule ); view->setWidget( widget ); view->setModel( proxyModel ); view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view->resizeColumnsToContents(); layout->addWidget(view); dialog->setWindowTitle(view->windowTitle()); QSize dialogSize = dialog->size(); double width = view->horizontalHeader()->length()+view->verticalHeader()->width()+5; if (model->rowCount() < 10) { // no scrollbar dialogSize.setHeight(view->horizontalHeader()->height()+model->rowCount()*30+5); dialogSize.setWidth(width); } else { // scrollbar is needed dialogSize.setHeight(width/1.618); dialogSize.setWidth(width+view->verticalScrollBar()->width()); } dialog->resize(dialogSize); dialog->setWindowFlags(Qt::Window); dialog->show(); return undo; }