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] Make QWidget Child clickable
Forum Update on Monday, May 27th 2025

[SOLVED] Make QWidget Child clickable

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 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.
  • M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 16 Sept 2015, 12:03 last edited by mrjj
    #1

    Hi, its the following way correct as to enable your own widget
    to be clickable like a button is. (connectable from outside)

    override

    protected: virtual void mouseReleaseEvent ( QMouseEvent * event );

    add signal

    signals: void mouseReleased();

    in mouseReleaseEvent

    emit mouseReleased();

    and then in main
    connect ( ui->NotiMachineStatus, SIGNAL ( mouseReleased() ), this, SLOT ( StatusClicked() ) )
    

    Or is there a faster way ?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 16 Sept 2015, 14:35 last edited by
      #2

      That seems to be ok, although if it's suppose to behave like button why not use a QPushButton or derive from it?
      If it walks like a duck and quacks like a duck....
      You can make it flat if you don't want it to seem too conspicuous.

      M 1 Reply Last reply 16 Sept 2015, 20:35
      1
      • C Chris Kawa
        16 Sept 2015, 14:35

        That seems to be ok, although if it's suppose to behave like button why not use a QPushButton or derive from it?
        If it walks like a duck and quacks like a duck....
        You can make it flat if you don't want it to seem too conspicuous.

        M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 16 Sept 2015, 20:35 last edited by
        #3

        @Chris-Kawa
        Ok. well it is actually a bit duck like,
        but I needed multiple icons and it is more of a status area widget
        than a button. But I see the quacks.

        Thank you

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on 16 Sept 2015, 21:17 last edited by
          #4

          but I needed multiple icons and it is more of a status area widget than a button

          How about QStatusBar with flat QPushButtons added as permanent widgets then?

          M 1 Reply Last reply 16 Sept 2015, 21:35
          0
          • C Chris Kawa
            16 Sept 2015, 21:17

            but I needed multiple icons and it is more of a status area widget than a button

            How about QStatusBar with flat QPushButtons added as permanent widgets then?

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 16 Sept 2015, 21:35 last edited by
            #5

            @Chris-Kawa
            Well you kinda sold me the pushbutton idea as I need 4 of them and they all can be clicked.
            free signals I and assume it has paint stages so I could make a down effect.

            1 Reply Last reply
            0

            2/5

            16 Sept 2015, 14:35

            • Login

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