当前位置: 首页>>代码示例>>C++>>正文


C++ QDialog::reject方法代码示例

本文整理汇总了C++中QDialog::reject方法的典型用法代码示例。如果您正苦于以下问题:C++ QDialog::reject方法的具体用法?C++ QDialog::reject怎么用?C++ QDialog::reject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDialog的用法示例。


在下文中一共展示了QDialog::reject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drv_dialog

int drv_dialog(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9)
{
    handle_head* head = (handle_head*)a0;
    QDialog *self = (QDialog*)head->native;
    switch (drvid) {
    case DIALOG_INIT: {
        drvNewObj(a0,new QDialog);
        break;
    }
    case DIALOG_SETMODAL: {
        self->setModal(drvGetBool(a1));
        break;
    }
    case DIALOG_ISMODAL: {
        drvSetBool(a1,self->isModal());
        break;
    }
    case DIALOG_SETRESULT: {
        self->setResult(drvGetInt(a1));
        break;
    }
    case DIALOG_RESULT: {
        drvSetInt(a1,self->result());
        break;
    }
    case DIALOG_EXEC: {
        drvSetInt(a1,self->exec());
        break;
    }
    case DIALOG_DONE: {
        self->done(drvGetInt(a1));
        break;
    }
    case DIALOG_ACCEPT: {
        self->accept();
        break;
    }
    case DIALOG_REJECT: {
        self->reject();
        break;
    }
    case DIALOG_ONACCEPTED: {
        QObject::connect(self,SIGNAL(acceped()),drvNewSignal(self,a1,a2),SLOT(call()));
        break;
    }
    case DIALOG_ONREJECTED: {
        QObject::connect(self,SIGNAL(rejected()),drvNewSignal(self,a1,a2),SLOT(call()));
        break;
    }
    default:
        return 0;
    }
    return 1;
}
开发者ID:weigj,项目名称:loongide,代码行数:54,代码来源:cdrv.cpp

示例2: 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;
}
开发者ID:choenig,项目名称:qt-creator,代码行数:68,代码来源:addimagesdialog.cpp


注:本文中的QDialog::reject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。