gpt4 book ai didi

c++ - 带有 "Do not show this again"复选框的 QMessageBox

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:10:55 24 4
gpt4 key购买 nike

如何在下方显示带有“不再显示”复选框的消息框?

我想象的东西看起来像这样:

enter image description here

最佳答案

Qt 5.2 添加了将 QCheckBox 添加到 QMessageBox 的可能性。看看QMessageBox::setCheckbox

这是一些演示代码

if (this->showMsgBox) {
QCheckBox *cb = new QCheckBox("Okay I understand");
QMessageBox msgbox;
msgbox.setText("Am I nerve-wrecking?");
msgbox.setIcon(QMessageBox::Icon::Question);
msgbox.addButton(QMessageBox::Ok);
msgbox.addButton(QMessageBox::Cancel);
msgbox.setDefaultButton(QMessageBox::Cancel);
msgbox.setCheckBox(cb);

QObject::connect(cb, &QCheckBox::stateChanged, [this](int state){
if (static_cast<Qt::CheckState>(state) == Qt::CheckState::Checked) {
this->showMsgBox = false;
}
});

msgbox.exec();
}

关于c++ - 带有 "Do not show this again"复选框的 QMessageBox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35130673/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com