Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Remove ? button from Windows MessageDialog?
Forum Updated to NodeBB v4.3 + New Features

Remove ? button from Windows MessageDialog?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
12 Posts 4 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I igor_stravinsky

    Is there a way to get rid of the ? button in a Message Dialog in Qt Quick Controls 2 5.10?

    0_1531777080072_dialogDetail.png

    In my situation, the ? button doesn't have any functionality. The default Mac dialog works as a sheet, so it doesn't have this issue, but Windows does.

    DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #3

    @igor_stravinsky said in Remove ? button from Windows MessageDialog?:

    but Windows does.

    It's strange. On my Windows 10 5.10.0 x64, the default MessageDialog does not show the '?' button:

    0_1531834207900_1bfcda5c-41e8-49d9-9c39-b6f6a5f7cfc1-image.png

    Nor does the Dialog type:

    0_1531836026381_f276f160-1ee1-4f61-9335-5a5ffdc84c6a-image.png

    Unfortunately, there seems to be no way to access the flags of the dialog window in QML ...

    I 1 Reply Last reply
    1
    • DiracsbracketD Diracsbracket

      @igor_stravinsky said in Remove ? button from Windows MessageDialog?:

      but Windows does.

      It's strange. On my Windows 10 5.10.0 x64, the default MessageDialog does not show the '?' button:

      0_1531834207900_1bfcda5c-41e8-49d9-9c39-b6f6a5f7cfc1-image.png

      Nor does the Dialog type:

      0_1531836026381_f276f160-1ee1-4f61-9335-5a5ffdc84c6a-image.png

      Unfortunately, there seems to be no way to access the flags of the dialog window in QML ...

      I Offline
      I Offline
      igor_stravinsky
      wrote on last edited by
      #4

      @Diracsbracket
      Where are you seeing the version number as 10.5.10.0?

      I'm testing under Windows 10 Version 1803 (OS Build 17134.11)

      DiracsbracketD 1 Reply Last reply
      0
      • I igor_stravinsky

        @Diracsbracket
        Where are you seeing the version number as 10.5.10.0?

        I'm testing under Windows 10 Version 1803 (OS Build 17134.11)

        DiracsbracketD Offline
        DiracsbracketD Offline
        Diracsbracket
        wrote on last edited by Diracsbracket
        #5

        @igor_stravinsky said in Remove ? button from Windows MessageDialog?:

        Where are you seeing the version number as 10.5.10.0?

        I meant Windows 10 (Qt) 5.10.0 ... I have also tried with Qt 5.10.1, and Qt 5.11.0, all are OK in that respect.

        I 1 Reply Last reply
        0
        • DiracsbracketD Diracsbracket

          @igor_stravinsky said in Remove ? button from Windows MessageDialog?:

          Where are you seeing the version number as 10.5.10.0?

          I meant Windows 10 (Qt) 5.10.0 ... I have also tried with Qt 5.10.1, and Qt 5.11.0, all are OK in that respect.

          I Offline
          I Offline
          igor_stravinsky
          wrote on last edited by
          #6

          @Diracsbracket

          OK, now I understand the versioning nomenclature

          In the file showing the dialog I've got

          import QtQuick 2.10
          import QtQuick.Controls 2.3
          import QtQuick.Layouts 1.3
          import QtWebView 1.1
          import QtQuick.Dialogs 1.3
          

          And am creating the MessageDialog with

          MessageDialog {
                  id: contactRepPopup
                  title: "Datasheet not available"
                  icon: StandardIcon.Warning
                  text: "Contact your sales representative for a datasheet for this part"
                  onAccepted: {
                      contactRepPopup.close()
                  }
              }
          

          I'll start playing with the includes to see if that changes things.

          DiracsbracketD 1 Reply Last reply
          0
          • I igor_stravinsky

            @Diracsbracket

            OK, now I understand the versioning nomenclature

            In the file showing the dialog I've got

            import QtQuick 2.10
            import QtQuick.Controls 2.3
            import QtQuick.Layouts 1.3
            import QtWebView 1.1
            import QtQuick.Dialogs 1.3
            

            And am creating the MessageDialog with

            MessageDialog {
                    id: contactRepPopup
                    title: "Datasheet not available"
                    icon: StandardIcon.Warning
                    text: "Contact your sales representative for a datasheet for this part"
                    onAccepted: {
                        contactRepPopup.close()
                    }
                }
            

            I'll start playing with the includes to see if that changes things.

            DiracsbracketD Offline
            DiracsbracketD Offline
            Diracsbracket
            wrote on last edited by Diracsbracket
            #7

            @igor_stravinsky
            This is how it shows on my system:

            0_1531846835714_617d143f-bcc5-4c8a-8688-f4eddbb2906a-image.png

            Note: I call the dialog from within a Window element and it also works when invoked from within a ApplicationWindow element.

            #include <QGuiApplication>
            #include <QQmlApplicationEngine>
            
            int main(int argc, char *argv[])
            {
                QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
            
                QGuiApplication app(argc, argv);
            
                QQmlApplicationEngine engine;
                engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
                if (engine.rootObjects().isEmpty())
                    return -1;
            
                return app.exec();
            }
            
            import QtQuick 2.10
            import QtQuick.Controls 2.3
            import QtQuick.Layouts 1.3
            import QtWebView 1.1
            import QtQuick.Dialogs 1.3
            
            Window {
            //ApplicationWindow {
                visible: true
                width: 640
                height: 480
                title: qsTr("Hello World")
            
                MessageDialog {
                    id: contactRepPopup
                    title: "Datasheet not available"
                    icon: StandardIcon.Warning
                    text: "Contact your sales representative for a datasheet for this part"
            
                    onAccepted: {
                        contactRepPopup.close()
                    }
            
                    Component.onCompleted: visible = true
                }
            }
            
            I 1 Reply Last reply
            1
            • DiracsbracketD Diracsbracket

              @igor_stravinsky
              This is how it shows on my system:

              0_1531846835714_617d143f-bcc5-4c8a-8688-f4eddbb2906a-image.png

              Note: I call the dialog from within a Window element and it also works when invoked from within a ApplicationWindow element.

              #include <QGuiApplication>
              #include <QQmlApplicationEngine>
              
              int main(int argc, char *argv[])
              {
                  QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
              
                  QGuiApplication app(argc, argv);
              
                  QQmlApplicationEngine engine;
                  engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
                  if (engine.rootObjects().isEmpty())
                      return -1;
              
                  return app.exec();
              }
              
              import QtQuick 2.10
              import QtQuick.Controls 2.3
              import QtQuick.Layouts 1.3
              import QtWebView 1.1
              import QtQuick.Dialogs 1.3
              
              Window {
              //ApplicationWindow {
                  visible: true
                  width: 640
                  height: 480
                  title: qsTr("Hello World")
              
                  MessageDialog {
                      id: contactRepPopup
                      title: "Datasheet not available"
                      icon: StandardIcon.Warning
                      text: "Contact your sales representative for a datasheet for this part"
              
                      onAccepted: {
                          contactRepPopup.close()
                      }
              
                      Component.onCompleted: visible = true
                  }
              }
              
              I Offline
              I Offline
              igor_stravinsky
              wrote on last edited by
              #8

              @Diracsbracket Fascinating!

              I wonder why your results and mine are different. Notice that in your dialog the icon and text have a darker background, whereas in mine, only the OK button has the darker background.

              I'm running as a QApplication rather than a QGuiApplication. I had to make that change in order to use QtCharts. Could that be responsible for the different appearance?

              DiracsbracketD 1 Reply Last reply
              0
              • I igor_stravinsky

                @Diracsbracket Fascinating!

                I wonder why your results and mine are different. Notice that in your dialog the icon and text have a darker background, whereas in mine, only the OK button has the darker background.

                I'm running as a QApplication rather than a QGuiApplication. I had to make that change in order to use QtCharts. Could that be responsible for the different appearance?

                DiracsbracketD Offline
                DiracsbracketD Offline
                Diracsbracket
                wrote on last edited by Diracsbracket
                #9

                @igor_stravinsky said in Remove ? button from Windows MessageDialog?:

                Could that be responsible for the different appearance

                Aha! Yes it seems you're right. In the example above I replaced QGuiApplication with QApplication, and in that case I get:

                0_1531885879151_98c4d98a-faab-4984-97eb-bc7632b5c33a-image.png

                In that case however, if you use Dialog instead of MessageDialog, you don't have the "?", but you need to implement the contentItem of the dialog box yourself, which is of course very easy:

                0_1531889280176_53137088-e367-44ed-b320-585e0d5b19b7-image.png
                http://doc.qt.io/qt-5/qml-qtquick-dialogs-dialog.html#details
                http://doc.qt.io/qt-5/qtquickdialogs-systemdialogs-customdialogs-qml.html

                kkoehneK 1 Reply Last reply
                1
                • DiracsbracketD Diracsbracket

                  @igor_stravinsky said in Remove ? button from Windows MessageDialog?:

                  Could that be responsible for the different appearance

                  Aha! Yes it seems you're right. In the example above I replaced QGuiApplication with QApplication, and in that case I get:

                  0_1531885879151_98c4d98a-faab-4984-97eb-bc7632b5c33a-image.png

                  In that case however, if you use Dialog instead of MessageDialog, you don't have the "?", but you need to implement the contentItem of the dialog box yourself, which is of course very easy:

                  0_1531889280176_53137088-e367-44ed-b320-585e0d5b19b7-image.png
                  http://doc.qt.io/qt-5/qml-qtquick-dialogs-dialog.html#details
                  http://doc.qt.io/qt-5/qtquickdialogs-systemdialogs-customdialogs-qml.html

                  kkoehneK Offline
                  kkoehneK Offline
                  kkoehne
                  Moderators
                  wrote on last edited by
                  #10

                  There were a couple of changes in Qt regarding the infamous "What's this button":

                  Since Qt 5.8, the What's This button is not shown anymore for non-QWidget dialogs (see QTBUG-56239)

                  Since Qt 5.10, there's a global flag AA_DisableWindowContextHelpButton to disable the button by default in all dialogs.

                  Director R&D, The Qt Company

                  JonBJ DiracsbracketD 2 Replies Last reply
                  2
                  • kkoehneK kkoehne

                    There were a couple of changes in Qt regarding the infamous "What's this button":

                    Since Qt 5.8, the What's This button is not shown anymore for non-QWidget dialogs (see QTBUG-56239)

                    Since Qt 5.10, there's a global flag AA_DisableWindowContextHelpButton to disable the button by default in all dialogs.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #11

                    @kkoehne said in Remove ? button from Windows MessageDialog?:

                    Since Qt 5.10, there's a global flag AA_DisableWindowContextHelpButton to disable the button by default in all dialogs.

                    Since that corresponds to my original suggestion of using

                    self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
                    

                    I can't see why OP does not use that (the new global one if necessary/for preference). If you do not want the "Help button", why not just make the necessary call rather than agonising over all the differences/solutions across various Windows versions?

                    1 Reply Last reply
                    0
                    • kkoehneK kkoehne

                      There were a couple of changes in Qt regarding the infamous "What's this button":

                      Since Qt 5.8, the What's This button is not shown anymore for non-QWidget dialogs (see QTBUG-56239)

                      Since Qt 5.10, there's a global flag AA_DisableWindowContextHelpButton to disable the button by default in all dialogs.

                      DiracsbracketD Offline
                      DiracsbracketD Offline
                      Diracsbracket
                      wrote on last edited by Diracsbracket
                      #12

                      @kkoehne said in Remove ? button from Windows MessageDialog?:

                      Since Qt 5.10, there's a global flag AA_DisableWindowContextHelpButton to disable the button by default in all dialogs.

                      Awesome! Works beautifully, thanks!

                      int main(int argc, char *argv[])
                      {
                          QCoreApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton);
                          ...
                      }
                      

                      No need to use Dialog then.

                      1 Reply Last reply
                      1

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved