-1

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.

demonplus
  • 5,613
  • 12
  • 49
  • 68
Archie Gertsman
  • 1,601
  • 2
  • 17
  • 45
  • The "standard" `MessageBoxA` here is Windows-specific. So the answer is going to depend which platform(s) you're targeting. – MrEricSir Jan 09 '16 at 00:54
  • So anyone running Windows will be able to see the QMessageBox? Because what I'm making is for windows only. – Archie Gertsman Jan 09 '16 at 00:56
  • 2
    It's not very clear what you're asking -- whether your application uses Qt or not, and which type of message box is going to appear are decided at compile time. Are you expecting users to compile the source on their machine? – MrEricSir Jan 09 '16 at 01:13
  • No, I'm asking can any regular user (without Qt installed) running Windows open up a program written in Qt, and have access to the `QMessageBox`? Or will they only be able to see a message box if it is type `MessageBoxA`? If I was to release an application written in Qt for Windows only, could I avoid incorporating `MessageBoxA` entirely and just use `QMessageBox`? Or will that limit most users because they don't have Qt installed? – Archie Gertsman Jan 09 '16 at 01:18
  • 3
    There's no such thing as installing Qt for non-developer users. Your application needs to deploy the Qt runtime DLLs, the Visual C++ runtime DLLs, etc. from the installer, or you need to statically link against those runtimes. Neither is specific to making message boxes appear on the screen really. – MrEricSir Jan 09 '16 at 02:07

1 Answers1

0

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.

Ilie NEACSU
  • 530
  • 3
  • 12