Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. "Don't show this meesage again" checkbox in QMessagebox
Forum Updated to NodeBB v4.3 + New Features

"Don't show this meesage again" checkbox in QMessagebox

Scheduled Pinned Locked Moved Unsolved General and Desktop
38 Posts 8 Posters 2.8k Views 3 Watching
  • 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.
  • P Prathamesh

    @JonB Ok , so I have stored the value from registry using .value() method as -->
    value = settings.value('check_box_status', check_box_status)

    Now how do I proceed further. Could you please guide me further?

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

    @Prathamesh
    You need to read the doc page and the examples. That's what development is about. They even show you how to read back a value, what have you done about that?

    P 1 Reply Last reply
    0
    • JonBJ JonB

      @Prathamesh
      You need to read the doc page and the examples. That's what development is about. They even show you how to read back a value, what have you done about that?

      P Offline
      P Offline
      Prathamesh
      wrote on last edited by
      #28

      @JonB I have read the value from registry as I said using this line -->

              settings = QtCore.QSettings('ConTest', 'Check-Box status')
              settings.setValue("check_box_status", check_box_status)
              value = settings.value('check_box_status', check_box_status)
      

      So the 1st line will create a folder in registry by the name Check_box_status
      2nd line will store the value of chwck-box in registry and the 3rd line will read that value back from registry. Now my question is how to use this value to not show the pop-up again.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #29

        Hi,

        The logic has already been explained several times:

        1. Get the settings value
        2. Check what that value is
        3. Show or not the message box based on this value
        4. If the message box has been show, update the settings value

        In any case, you really should use more meaningful variable and key names. It would help you quite a lot with the code flow.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        P 1 Reply Last reply
        3
        • SGaistS SGaist

          Hi,

          The logic has already been explained several times:

          1. Get the settings value
          2. Check what that value is
          3. Show or not the message box based on this value
          4. If the message box has been show, update the settings value

          In any case, you really should use more meaningful variable and key names. It would help you quite a lot with the code flow.

          P Offline
          P Offline
          Prathamesh
          wrote on last edited by
          #30

          @SGaist That is what my question is actually. The logic is understood, but the 3rd point u have mentioned is the actual problem. How to use this value to not show the pop-up. That is what I want to know.

          jsulmJ 1 Reply Last reply
          0
          • P Prathamesh

            @SGaist That is what my question is actually. The logic is understood, but the 3rd point u have mentioned is the actual problem. How to use this value to not show the pop-up. That is what I want to know.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #31

            @Prathamesh said in "Don't show this meesage again" checkbox in QMessagebox:

            but the 3rd point u have mentioned is the actual problem

            The third point is a simple if () statement checking the value of the setting...

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            P 1 Reply Last reply
            1
            • jsulmJ jsulm

              @Prathamesh said in "Don't show this meesage again" checkbox in QMessagebox:

              but the 3rd point u have mentioned is the actual problem

              The third point is a simple if () statement checking the value of the setting...

              P Offline
              P Offline
              Prathamesh
              wrote on last edited by
              #32

              @jsulm Of course it is if statement, my question was not about how to check the value. My question was how to use that value to show message-box or not to show it. I hope this time it is clear.

              Pl45m4P 1 Reply Last reply
              0
              • P Prathamesh

                @jsulm Of course it is if statement, my question was not about how to check the value. My question was how to use that value to show message-box or not to show it. I hope this time it is clear.

                Pl45m4P Offline
                Pl45m4P Offline
                Pl45m4
                wrote on last edited by Pl45m4
                #33

                @Prathamesh

                How you would do it without QSettings? Same thing. Doesn't matter where the bool is coming from. Set it somewhere (member / class var) and then put the check before the code that shows the messageBox.
                I don't see any problem or difficulty there...


                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                P 1 Reply Last reply
                2
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #34

                  @Prathamesh said in "Don't show this meesage again" checkbox in QMessagebox:

                  hi you just need to adjust your logic

                   settings = QtCore.QSettings('ConTest', 'Check-Box status')
                   IsHidden = settings.value('check_box_status', check_box_status)
                  
                  if  not IsHidden :     // its one block   
                    msg = QtWidgets.QMessageBox()
                    msg.setWindowTitle("What's New")
                    msg.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
                    msg.setText(ui_helper.WHAT_IS_NEW)
                    check_box = QtWidgets.QCheckBox("Don't show this again")
                    msg.setCheckBox(check_box)
                    msg.exec_()
                    check_box_status = check_box.isChecked()
                    settings.setValue("check_box_status", check_box_status)
                  
                  P 1 Reply Last reply
                  1
                  • mrjjM mrjj

                    @Prathamesh said in "Don't show this meesage again" checkbox in QMessagebox:

                    hi you just need to adjust your logic

                     settings = QtCore.QSettings('ConTest', 'Check-Box status')
                     IsHidden = settings.value('check_box_status', check_box_status)
                    
                    if  not IsHidden :     // its one block   
                      msg = QtWidgets.QMessageBox()
                      msg.setWindowTitle("What's New")
                      msg.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
                      msg.setText(ui_helper.WHAT_IS_NEW)
                      check_box = QtWidgets.QCheckBox("Don't show this again")
                      msg.setCheckBox(check_box)
                      msg.exec_()
                      check_box_status = check_box.isChecked()
                      settings.setValue("check_box_status", check_box_status)
                    
                    P Offline
                    P Offline
                    Prathamesh
                    wrote on last edited by
                    #35

                    @mrjj Hi , I have one doubt here. The settings variable here is creating a folder in windows registry editor. But my question is, when i close my application and relaunch it again, will this settings variable not create one more folder?

                    Pl45m4P 1 Reply Last reply
                    0
                    • P Prathamesh

                      @mrjj Hi , I have one doubt here. The settings variable here is creating a folder in windows registry editor. But my question is, when i close my application and relaunch it again, will this settings variable not create one more folder?

                      Pl45m4P Offline
                      Pl45m4P Offline
                      Pl45m4
                      wrote on last edited by Pl45m4
                      #36

                      @Prathamesh said in "Don't show this meesage again" checkbox in QMessagebox:

                      But my question is, when i close my application and relaunch it again, will this settings variable not create one more folder?

                      Therefore the settings have a key string. So that the same, stored value is read in again.

                      • https://doc.qt.io/qt-5/qsettings.html#qvariant-and-gui-types
                      • https://doc.qt.io/qt-5/qsettings.html#section-and-key-syntax

                      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                      ~E. W. Dijkstra

                      1 Reply Last reply
                      2
                      • Pl45m4P Pl45m4

                        @Prathamesh

                        How you would do it without QSettings? Same thing. Doesn't matter where the bool is coming from. Set it somewhere (member / class var) and then put the check before the code that shows the messageBox.
                        I don't see any problem or difficulty there...

                        P Offline
                        P Offline
                        Prathamesh
                        wrote on last edited by
                        #37

                        Ok, So should I go ahead with this code?

                        SGaistS 1 Reply Last reply
                        0
                        • P Prathamesh

                          Ok, So should I go ahead with this code?

                          SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #38

                          @Prathamesh said in "Don't show this meesage again" checkbox in QMessagebox:

                          Ok, So should I go ahead with this code?

                          Yes.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0

                          • Login

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