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
QtWS25 Last Chance

[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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on 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
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on 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.

      mrjjM 1 Reply Last reply
      1
      • Chris KawaC Chris Kawa

        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.

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on 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
        • Chris KawaC Online
          Chris KawaC Online
          Chris Kawa
          Lifetime Qt Champion
          wrote on 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?

          mrjjM 1 Reply Last reply
          0
          • Chris KawaC Chris Kawa

            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?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on 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

            • Login

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