How can I use QMessageBox::About differently
-
How can I use it in a different way as I mentioned in the title.
I'm planning to do it in the form of the code below, but I couldn't.QMessageBox msgBox; msgBox.setWindowIcon(QIcon(":/image/52379312.png")); msgBox.setIcon(QMessageBox::About); msgBox.setWindowTitle(tr("About")); msgBox.setText(tr("Text_TEXT"); QAbstractButton* xokey = msgBox.addButton(tr("Okey"), QMessageBox::YesRole);
-
@HerrWinfried said in How can I use QMessageBox::About differently:
but I couldn't.
What does this mean?
-
Im not sure what you mean by different but for the code shown, don't you miss the part where you show it ?
Like
msgBox.exec(); -
Let me explain what I want to do, I want to use the code I mentioned above, but in a way that will run QMessageBox::About
So
QMessageBox::About(this, "Title", "Message")
I want to revert the code to this, but I don't know how to do it.
QMessageBox msgBox; msgBox.setWindowIcon(QIcon(":/image/52379312.png")); msgBox.setIcon(QMessageBox::About); msgBox.setWindowTitle(tr("About")); msgBox.setText(tr("Text_TEXT"); QAbstractButton* xokey = msgBox.addButton(tr("Okey"), QMessageBox::YesRole); msgBox.exec();
I have no idea how to translate sorry for bad english.
-
Hi
You mean like this ?
QMessageBox msgBox; msgBox.setWindowTitle(tr("Title")); msgBox.setText(tr("Message")); msgBox.setStandardButtons(QMessageBox::StandardButton::Ok); msgBox.setIcon(QMessageBox::Information);
-
@HerrWinfried
Hi
I think that is what confuses me :) - as on windows the code
QMessageBox::about(this, "Title", "Message");shows
-
@mrjj said in How can I use QMessageBox::About differently:
@HerrWinfried
Hi
I think that is what confuses me :) - as on windows the code
QMessageBox::about(this, "Title", "Message");shows
It takes whatever icon of the working form file is, otherwise it will be empty.
-
@HerrWinfried
Ahh. you have this image set as a windows icon ?
Or where did you set it before showing the MsgBox ? -
@mrjj said in How can I use QMessageBox::About differently:
@HerrWinfried
Ahh. you have this image set as a windows icon ?
Or where did you set it before showing the MsgBox ?Just asking because I don't know, I know as QMessageBox::About
-
@HerrWinfried
So you did not load this image your self at any point in the app ?It just sort of get its some where ?
What platform are you on ?
update: ah it does take the Window icon.
-
@mrjj , @HerrWinfried
Not sure what exactly you two are debating. Have you looked at the source of QMessageBox::about()?And it uses
QIcon icon = msgBox->windowIcon();
\property QWidget::windowIcon \brief the widget's icon This property only makes sense for windows. If no icon has been set, windowIcon() returns the application icon (QApplication::windowIcon()).
-
@HerrWinfried Customise QMessageBox with pixmap or icon
QMessageBox *infoMSG = new QMessageBox(this); infoMSG->setMaximumSize(400,200); infoMSG->setStyleSheet("background-color: rgb(167, 210, 219); color:rgb(0,0,0);"); infoMSG->setIconPixmap(QPixmap(":/images/Green-true.png").scaled(QSize(30,30))); infoMSG->setWindowIcon(QIcon(":/images/Admin-logo.png")); infoMSG->setWindowTitle("Title"); infoMSG->setText("Message"); infoMSG->addButton(QMessageBox::Ok)->setMinimumSize(80,30); infoMSG->buttons().at(0)->setStyleSheet("background-color: rgb(255,153,153);color:rgb(0,0,102);"); infoMSG->exec();