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. [Solved] Problem clicking QPushButton with a menu
Forum Update on Monday, May 27th 2025

[Solved] Problem clicking QPushButton with a menu

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 4.2k 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.
  • S Offline
    S Offline
    SKolaMunn
    wrote on 29 Feb 2012, 21:23 last edited by
    #1

    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
    0
    • B Offline
      B Offline
      Blizzard
      wrote on 2 Mar 2012, 17:23 last edited by
      #2

      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
      0
      • S Offline
        S Offline
        SKolaMunn
        wrote on 2 Mar 2012, 17:32 last edited by
        #3

        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
        0
        • B Offline
          B Offline
          Blizzard
          wrote on 2 Mar 2012, 18:07 last edited by
          #4

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

          Software Engineer | Aerospace & Defence

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SKolaMunn
            wrote on 2 Mar 2012, 19:31 last edited by
            #5

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

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SKolaMunn
              wrote on 2 Mar 2012, 19:33 last edited by
              #6

              Sorry, guess it was already added.

              Thanks

              1 Reply Last reply
              0
              • B Offline
                B Offline
                Blizzard
                wrote on 2 Mar 2012, 19:34 last edited by
                #7

                Prefix the subject with [Solved]

                Software Engineer | Aerospace & Defence

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  Blizzard
                  wrote on 2 Mar 2012, 19:35 last edited by
                  #8
                  • in addition to tagging it at solved

                  Software Engineer | Aerospace & Defence

                  1 Reply Last reply
                  0

                  1/8

                  29 Feb 2012, 21:23

                  • Login

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