[Interest] QMessageBox::critical VS custom: discrepancies

Sensei senseiwa at gmail.com
Mon Oct 8 16:18:12 CEST 2012


Dear all,

I am moving some old QMessageBox::critical (and functions alike) to a 
Mac-aware UI. This means, according to the documentation, using a more 
verbose code, with an informative text.

However, the widths of the static version VS my custom are quite 
different. Even more, the location in which they appear is different. It 
seems that the custom is placed on the center of the screen, while the 
static on the center of the application window!

This is the ubersimple code:


         QMessageBox msg;
         msg.setWindowTitle(tr("Error"));
         msg.setIcon(QMessageBox::Critical);
         msg.setText("Cannot create the project.");
         msg.setInformativeText("An error occurred while creating the 
project folder. Please try again selecting another location.");
         msg.setStandardButtons(QMessageBox::Ok);
         msg.setDefaultButton(QMessageBox::Ok);
         msg.exec();

         QMessageBox::critical(this, tr("Error"), tr("Cannot create the 
project. Please try again on a different folder."));



Do you know how I can make my custom messagebox look exactly like the 
static version?

I can settle for an "almost exactly" :)




Thanks & Cheers!





More information about the Interest mailing list