PDA

View Full Version : How to add a a Button to a QMessageBox?



Bong.Da.City
28th August 2010, 11:05
I am making a program.. And i had add an about button which shows a QMessageBox..


void MainWindow::on_aboutButton_clicked()
{
QMessageBox msgBox;
msgBox.setText("<b><big>Putsa pali! </big><b>");
msgBox.setInformativeText("By <b>putsos</b> and <b>muni</b>. If you like it, visit our <a href=http://www.qjdfkjfbhjebfebfiofu.com>webpage</a>!");
msgBox.setWindowTitle("Putsa pali | About");
msgBox.setIconPixmap(QIcon(":/icons/putsa.png").pixmap(QSize(64,64)));
msgBox.setWindowIcon(QIcon(":/icons/putsa.png"));
msgBox.exec();
}


So how can i add a Button ( i want to add a Button "How it was Developed") left to the ok button which will close the about QMessageBox and show the How it was developed QMessageBox... ?

berlinud
28th August 2010, 14:46
Maybe you should try to derive a new class from QMessageBox.

Bong.Da.City
28th August 2010, 15:03
Ok and how to do that?

saa7_go
29th August 2010, 10:19
Maybe, you can experiment with QMessageBox::addButton(QAbstractButton*, ButtonRole) (http://doc.trolltech.com/4.6/qmessagebox.html#addButton), QMessageBox::addButton(const QString &, ButtonRole) (http://doc.trolltech.com/4.6/qmessagebox.html#addButton-2), QMessageBox::addButton(StandardButton) (http://doc.trolltech.com/4.6/qmessagebox.html#addButton-3), and QMessageBox::clickedButton() (http://doc.trolltech.com/4.6/qmessagebox.html#clickedButton).

berlinud
29th August 2010, 10:37
Ok and how to do that?

I haven't actually done that,I suggest you checking the document of qt,check for the class structure of QMessageBox,and find out by which function it adds buttons,and you may overload the function.

But I recommend you to derive a class from QWidget,I think qt don't recommend using QMessageBox as a base class.

cheer up and try that;)

Bong.Da.City
29th August 2010, 20:02
Never mind.. I will just create some QDialogs :)...