Qt Forum

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

    [SOLVED] Make QWidget Child clickable

    General and Desktop
    2
    5
    2089
    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.
    • mrjj
      mrjj Lifetime Qt Champion last edited by mrjj

      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 Reply Quote 0
      • Chris Kawa
        Chris Kawa Moderators last edited by

        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.

        mrjj 1 Reply Last reply Reply Quote 1
        • mrjj
          mrjj Lifetime Qt Champion @Chris Kawa last edited by

          @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 Reply Quote 0
          • Chris Kawa
            Chris Kawa Moderators last edited by

            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?

            mrjj 1 Reply Last reply Reply Quote 0
            • mrjj
              mrjj Lifetime Qt Champion @Chris Kawa last edited by

              @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 Reply Quote 0
              • First post
                Last post