本文整理汇总了C++中QDialog::deleteLater方法的典型用法代码示例。如果您正苦于以下问题:C++ QDialog::deleteLater方法的具体用法?C++ QDialog::deleteLater怎么用?C++ QDialog::deleteLater使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDialog
的用法示例。
在下文中一共展示了QDialog::deleteLater方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
void Fix8Log::aboutSlot()
{
QDialog *aboutDialog = new QDialog();
QVBoxLayout *aboutLayout = new QVBoxLayout(0);
QDialogButtonBox *dialogButtonBox = new QDialogButtonBox();
dialogButtonBox->addButton(QDialogButtonBox::Ok);
connect(dialogButtonBox,SIGNAL(clicked(QAbstractButton*)),
aboutDialog,SLOT(close()));
QQuickView *aboutView = new QQuickView(QUrl("qrc:qml/helpAbout.qml"));
QQuickItem *qmlObject = aboutView->rootObject();
qmlObject->setProperty("color",aboutDialog->palette().color(QPalette::Window));
qmlObject->setProperty("bgColor",aboutDialog->palette().color(QPalette::Window));
qmlObject->setProperty("version",QString::number(Globals::version));
aboutView->setResizeMode(QQuickView::SizeRootObjectToView);
QWidget *aboutWidget = QWidget::createWindowContainer(aboutView,0);
aboutWidget->setPalette(aboutDialog->palette());
aboutWidget->setAutoFillBackground(false);
aboutDialog->setLayout(aboutLayout);
aboutLayout->addWidget(aboutWidget,1);
aboutLayout->addWidget(dialogButtonBox,0);
aboutDialog->resize(500,400);
aboutDialog->setWindowTitle(GUI::Globals::appName);
aboutDialog->exec();
aboutDialog->deleteLater();
}
示例2: testWaitEndedByModalDialog
void WaitForWindowTest::testWaitEndedByModalDialog() {
WaitForWindow waitForWindow("theName");
waitForWindow.setActive(true);
//WaitFor* must be registered in order to be used with QSignalSpy
int waitForStarType = qRegisterMetaType<WaitFor*>("WaitFor*");
QSignalSpy waitEndedSpy(&waitForWindow, SIGNAL(waitEnded(WaitFor*)));
QDialog* modalDialog = new QDialog(mMainWindow); //krazy:exclude=qclasses
modalDialog->setObjectName("theName");
QTimer timerAccept;
timerAccept.setSingleShot(true);
timerAccept.setInterval(1500);
connect(&timerAccept, SIGNAL(timeout()), modalDialog, SLOT(accept()));
//Check that the condition was met before closing the modal dialog to ensure
//that the processing of events or signals is not halted due to being modal.
queueAssertConditionMet(&waitForWindow, &waitEndedSpy, 500);
timerAccept.start();
modalDialog->exec(); //krazy:exclude=crashy
modalDialog->deleteLater();
QVERIFY(waitForWindow.conditionMet());
QCOMPARE(waitEndedSpy.count(), 1);
QVariant argument = waitEndedSpy.at(0).at(0);
QCOMPARE(argument.userType(), waitForStarType);
QCOMPARE(qvariant_cast<WaitFor*>(argument), &waitForWindow);
}
示例3: RunFormDialog
bool RunFormDialog (QWidget *widget)
{
QDialog *dialog (new QDialog ());
dialog->setWindowTitle (widget->windowTitle ());
dialog->setLayout (new QVBoxLayout ());
dialog->layout ()->addWidget (widget);
QDialogButtonBox *box = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
dialog->layout ()->addWidget (box);
QObject::connect (box,
SIGNAL (accepted ()),
dialog,
SLOT (accept ()));
QObject::connect (box,
SIGNAL (rejected ()),
dialog,
SLOT (reject ()));
const bool result = dialog->exec () == QDialog::Accepted;
dialog->deleteLater ();
return result;
}
示例4: getDirectory
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;
}
示例5: edit
//.........这里部分代码省略.........
for(auto &name : m_characterNames) {
namesList->addItem(name);
}
namesLayout->addWidget(namesList);
QPushButton *addName = new QPushButton(QObject::tr("&Add"));
namesLayout->addWidget(addName);
QObject::connect(addName, &QPushButton::clicked,
[=](){
bool ok = true;
QString name = QInputDialog::getText(dialog,
QObject::tr("New name"),
QObject::tr("Enter new character name:"), QLineEdit::Normal,
"", &ok);
if(ok) namesList->addItem(name);
else namesList->addItem("????");
});
QPushButton *removeName = new QPushButton(QObject::tr("&Delete"));
QObject::connect(removeName, &QPushButton::clicked,
[=](){
for(auto it : namesList->selectedItems()) {
delete it;
}
});
namesLayout->addWidget(removeName);
QWidget *namesWidget = new QWidget();
namesWidget->setLayout(namesLayout);
tabs->addTab(namesWidget, QObject::tr("Character names"));
// Contexts tab
auto contextsLayout = new QVBoxLayout();
QMap<int, QStandardItem *> contextMap;
auto contextsModel = makeContextModel(contextMap, true);
auto contextsView = new QTreeView();
contextsView->setHeaderHidden(true);
contextsView->setModel(contextsModel);
contextsView->setDragDropMode(QAbstractItemView::InternalMove);
contextsLayout->addWidget(contextsView);
auto addContext = new QPushButton(QObject::tr("&Add"));
QObject::connect(addContext, &QPushButton::clicked,
[=](){
bool ok = true;
QString name = QInputDialog::getText(dialog,
QObject::tr("New context name"),
QObject::tr("Enter new context name:"), QLineEdit::Normal,
"", &ok);
if(!ok) name = "????";
int id = getAvailableID();
auto con = m_contexts[id] = new ConversationContext(id);
con->setLabel(name);
auto item = makeContextItem(con, true);
contextMap[rootContext()->id()]->appendRow(item);
});
contextsLayout->addWidget(addContext);
auto removeContext = new QPushButton(QObject::tr("&Delete"));
QObject::connect(removeContext, &QPushButton::clicked,
[=](){
qDebug("Removal NYI");
});
contextsLayout->addWidget(removeContext);
auto contextsWidget = new QWidget();
contextsWidget->setLayout(contextsLayout);
tabs->addTab(contextsWidget, QObject::tr("Node contexts"));
dialog->exec();
// Character tab
m_characterNames.clear();
while(namesList->count() > 0) {
m_characterNames.push_back(namesList->takeItem(0)->text());
}
// Contexts tab
// XXX: local function replacement
class ContextsRearranger {
public:
static void rearrange(QMap<int, ConversationContext *> &contexts,
QStandardItem *item) {
auto thisID = item->data(0x100).toInt();
auto thisContext = contexts[thisID];
for(int i = 0; i < item->rowCount(); i ++) {
auto it = item->child(i);
auto id = it->data(0x100).toInt();
contexts[id]->setParent(thisContext);
contexts[id]->setLabel(it->text());
rearrange(contexts, item->child(i));
}
}
};
ContextsRearranger::rearrange(m_contexts, contextMap[rootContext()->id()]);
// TODO: delete all unparented contexts
dialog->deleteLater();
}