QT 学习之 Dialog

应用场景:当界面运行后需要出现一个对话框,就选择创建dialog

dialog 分为模态和半模态

  • 自定义对话框未关闭时,不可以对父窗口进行操作创造对话框对象后,与exec()配合使用,程序执行到exec()时,如果不对对话框进行操作,后面的代码不会执行。

  • 当自定义对话框未关闭时,还可以对父窗口进行操作。常用于需要进行界面交互操作的情况

  • m_configurationDialog = new ParameterconfigurationDialog(this);
        m_configurationDialog->exec();
        if (m_configurationDialog->result() == QDialog::Accepted) {
            m_configurationDialog->close();
            m_sIp = m_configurationDialog->sIp();
            m_dIp = m_configurationDialog->dIp();
            m_agreement = m_configurationDialog->agreement();
            m_number = m_configurationDialog->number();
            m_port = m_configurationDialog->port();
            CMDID::instance()->setcmdID(m_number);
        } else if (m_configurationDialog->result() == QDialog::Rejected) {
            delete m_configurationDialog;//删除对话框
            return;
        }
        delete m_configurationDialog;
    
    void ParameterconfigurationDialog::on_pb_save_clicked()
    {
        m_sIp = ui->le_SystemIp->text();
        m_dIp = ui->le_DeviceIp->text();
        m_agreement = ui->cb_Agreement->currentText();
        m_number = ui->le_Number->text();
        m_port = ui->le_Port->text();
        emit sigSendData(m_sIp, m_dIp, m_agreement, m_number);
        this->accept();
        this->close();
    }

    当点击dialog右上角的x时,会自动触发reject()函数二、各种字符的相互转换

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值