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. Pushbutton promoted from QPushButton is invisible
QtWS25 Last Chance

Pushbutton promoted from QPushButton is invisible

Scheduled Pinned Locked Moved Solved General and Desktop
qpushbuttonpromotesubclassing
4 Posts 3 Posters 1.1k 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.
  • J Offline
    J Offline
    JJLee
    wrote on last edited by JJLee
    #1

    I promoted a QPushButton in QtDesigner to myPushButton.

    I created myPushButton.h and myPushButton.cpp

    The ui_mainwindow.h file shows an object myPushButton being instantiated just like all the other QPushButtons. The constructor for myPushButton is the same in ui_mainwindow.h as all the normal QPushButtons. This all compiles correctly.

    When I run my application, myPushButton is invisible.

    But I can mouse over myPushButton and click the mouse, and the expected behavior occurs, i.e. myPushButton is clicked as expected. I have a text output signal that writes to a log window, and I see the correct text message when the myPushButton is pressed.

    So everything seems to work fine, the button is there in the layout, but the button is invisible.

    Does anyone understand why this happens? Do subclassed/promoted widgets need some sort of special display information to become visible?

    Thanks for any help.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Did you overwrite the paint() event? Or why did you derive from QPushButton?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • J Offline
        J Offline
        JJLee
        wrote on last edited by
        #3

        Thanks for your question, it led me to the solution!

        I derived from QPushButton because I'm porting to a touch screen on an embedded system, and I need to override QPushButton's "event" member function to process touch events properly.

        If the event type is not a touch panel event, I pass the event to the base class QPushButton.

        I was capturing "spontaneous" events (which include the paint event), and not passing them to the base class.

        So I removed the section that captured the spontaneous event, and things work as expected now.

        Thanks so much for taking the time to respond on a weekend. Kudos to you!

        Pablo J. RoginaP 1 Reply Last reply
        0
        • J JJLee

          Thanks for your question, it led me to the solution!

          I derived from QPushButton because I'm porting to a touch screen on an embedded system, and I need to override QPushButton's "event" member function to process touch events properly.

          If the event type is not a touch panel event, I pass the event to the base class QPushButton.

          I was capturing "spontaneous" events (which include the paint event), and not passing them to the base class.

          So I removed the section that captured the spontaneous event, and things work as expected now.

          Thanks so much for taking the time to respond on a weekend. Kudos to you!

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @JJLee said in Pushbutton promoted from QPushButton is invisible:

          it led me to the solution!

          great! so please don't forget to mark your post as solved then.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          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