Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [Solved] Problem clicking QPushButton with a menu

    General and Desktop
    2
    8
    3719
    Loading More Posts
    • 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.
    • S
      SKolaMunn last edited by

      I made a custom widget in QT Designer. In this custom widget, I have a QPushButton. In my code, I make a menu for this button and set it using QPushButton::setMenu. I do this throughout my code in custom widgets that I wrote without Designer. For some reason, I have a problem with the widget that I made in Designer. In order to activate the button's menu, I have to click only on the right border of the button. If I click anywhere else within the button or its border, my click is not registered, but if I click on the right edge, the menu pops down as desired. Is this a known bug? Does anyone have any suggestions on how to fix this?

      I do not set any special style sheet on my button (left the styleSheet line in Designer blank), I do not have any other actions connected to this button. I did mark this as a "flat" button, but I tried it with and without the "flat" property checked in Designer and both ways give the same problem. The button only registers a click when I click on the right edge.

      Suggestions are appreciated!

      1 Reply Last reply Reply Quote 0
      • B
        Blizzard last edited by

        This is not a bug, there is a problem in your code. Please post the relevant code so we can help.

        Software Engineer | Aerospace & Defence

        1 Reply Last reply Reply Quote 0
        • S
          SKolaMunn last edited by

          I just found the problem and solution this morning.

          I was using a class written by a colleague and did not realize that it inherited QWidget in order to use winEvent. My object of that class was not being explicitly added to my form and so it was automatically placed at (0,0) and was covering my button. I fixed the problem by setting the size of the widget using setFixedSize(0,0).

          I understand that its helpful to post code when posting problems but its hard to determine the relevant code when my class using the ui had 5000 lines of code and was not doing anything explicitly to the button other than setting a menu on it. I guess my question was really how to go about investigating the problem because I had no idea what code was relevant to post!

          1 Reply Last reply Reply Quote 0
          • B
            Blizzard last edited by

            Don't forget to add [solved] to your post

            Software Engineer | Aerospace & Defence

            1 Reply Last reply Reply Quote 0
            • S
              SKolaMunn last edited by

              How do I mark it as solved? I assume I need to add a tag, but don't see where.

              1 Reply Last reply Reply Quote 0
              • S
                SKolaMunn last edited by

                Sorry, guess it was already added.

                Thanks

                1 Reply Last reply Reply Quote 0
                • B
                  Blizzard last edited by

                  Prefix the subject with [Solved]

                  Software Engineer | Aerospace & Defence

                  1 Reply Last reply Reply Quote 0
                  • B
                    Blizzard last edited by

                    • in addition to tagging it at solved

                    Software Engineer | Aerospace & Defence

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post