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.5k 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 Offline
    I Offline
    igor_stravinsky
    wrote on 16 Jul 2018, 21:39 last edited by
    #1

    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.

    J D 2 Replies Last reply 17 Jul 2018, 08:16
    0
    • I igor_stravinsky
      16 Jul 2018, 21:39

      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.

      J Offline
      J Offline
      JonB
      wrote on 17 Jul 2018, 08:16 last edited by
      #2

      @igor_stravinsky
      I don't know anything about Quick Controls, but assuming your ? icon is the same thing I use (Python):

              # None of our dialogs support Windows context help "?" button
              self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
      
      
      1 Reply Last reply
      2
      • I igor_stravinsky
        16 Jul 2018, 21:39

        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.

        D Offline
        D Offline
        Diracsbracket
        wrote on 17 Jul 2018, 14:00 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 17 Jul 2018, 16:35
        1
        • D Diracsbracket
          17 Jul 2018, 14:00

          @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 17 Jul 2018, 16:35 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)

          D 1 Reply Last reply 17 Jul 2018, 16:44
          0
          • I igor_stravinsky
            17 Jul 2018, 16:35

            @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)

            D Offline
            D Offline
            Diracsbracket
            wrote on 17 Jul 2018, 16:44 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 17 Jul 2018, 16:48
            0
            • D Diracsbracket
              17 Jul 2018, 16:44

              @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 17 Jul 2018, 16:48 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.

              D 1 Reply Last reply 17 Jul 2018, 17:03
              0
              • I igor_stravinsky
                17 Jul 2018, 16:48

                @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.

                D Offline
                D Offline
                Diracsbracket
                wrote on 17 Jul 2018, 17:03 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 17 Jul 2018, 18:11
                1
                • D Diracsbracket
                  17 Jul 2018, 17:03

                  @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 17 Jul 2018, 18:11 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?

                  D 1 Reply Last reply 18 Jul 2018, 03:51
                  0
                  • I igor_stravinsky
                    17 Jul 2018, 18:11

                    @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?

                    D Offline
                    D Offline
                    Diracsbracket
                    wrote on 18 Jul 2018, 03:51 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

                    K 1 Reply Last reply 18 Jul 2018, 08:32
                    1
                    • D Diracsbracket
                      18 Jul 2018, 03:51

                      @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

                      K Offline
                      K Offline
                      kkoehne
                      Moderators
                      wrote on 18 Jul 2018, 08:32 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

                      J D 2 Replies Last reply 18 Jul 2018, 08:37
                      2
                      • K kkoehne
                        18 Jul 2018, 08:32

                        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.

                        J Offline
                        J Offline
                        JonB
                        wrote on 18 Jul 2018, 08:37 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
                        • K kkoehne
                          18 Jul 2018, 08:32

                          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.

                          D Offline
                          D Offline
                          Diracsbracket
                          wrote on 18 Jul 2018, 08:39 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

                          7/12

                          17 Jul 2018, 17:03

                          • Login

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