Search code examples
c++qtqmessagebox

QMessageBox Compatibility


I'm looking through some Qt code and see that rather than just using QMessageBox, the program checks whether QAPPLICATION_H is defined. If it isn't, then it uses some default system message box. Here's what it looks like:

bool Connect()
{
        ...
        {
#ifdef QAPPLICATION_H
            QMessageBox::critical(0,QString("Error!"),QString("Cannot Connect To PS3"));
#else
            MessageBoxA(0,"Error!","Cannot Connect To PS3",MB_ICONINFORMATION);
#endif
            return false;
        }
        else
        {
            ...
            #ifdef QAPPLICATION_H
            QMessageBox::information(0,QString("Sucess!"),QString("Connected To PS3!"));
#else
            MessageBoxA(0,"Sucess!", "Connected To PS3", MB_ICONINFORMATION);
#endif
            return true;

        }
}

Basically, my question is: what's the compatibility of QMessageBox? If I released a program that only uses QMessageBox, will people without Qt not be able to see the message pop up? I just don't want to have to check for this every time in my own code, and also the standard non-Qt box looks worse.


Solution

  • Qt is cross platform QMessageBox will be available on any platform you compile your code. I don't know why in the listed code is that define and the call to MessageBoxA, maybe the developer wanted to be able to display a more windows look and feel message box, in case the target platform is windows.