Search code examples
c++qtwindowqwidget

Check if Window-Title is visible


Short Question: Is there a Qt-way to find out whether the windowing system does show titles or not? Example:

Windows - With window titles:

Windows window

OsX - No window title:

OsX Window

I used the same code to generate these boxes:

QMessageBox::information(NULL, "Information", "This is an example dialog");

As you can see, the "Information" will only be shown on windows - What I want to know is how to determine if the windowing system can display window titles or not.

I couldn't find anything in the documentation about it, but maybe it's somwhere hidden, e.g. in the native interface?


Solution

  • If you interesting, here is how title to show up in your QMessageBox on Mac.

    QMessageBox msgBox("", "This is an example dialog", QMessageBox::Information, 0, 0, 0, nullptr, Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
    msgBox.QDialog::setWindowTitle("Information");
    msgBox.exec();
    

    You can check system with QSysInfo. QSysInfo gives run time details about system. More can you read: QSysInfo. Here is example, where you detect IOS systems and use Q_WS_* macros.

    #include <QSysInfo>
    #ifdef Q_WS_MAC
    switch(QSysInfo::MacintoshVersion())
    {
      case QSysInfo::MV_IOS: return "IOS";//all IOS versions
      default: return "Windows";
    }
    #endif