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]Change the view of widget when hover on QPushButton or other QWidget without inheritance
QtWS25 Last Chance

[Solved]Change the view of widget when hover on QPushButton or other QWidget without inheritance

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.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
    stereomatching
    wrote on last edited by
    #1

    Assume that I have a QPushButton and a QTableView
    When my mouse hover on the QPushButton
    I want to change the appearance of the QTableView
    Could I make this happen without inherit QPushButton
    and override the mouseEvent(or other member function)?

    This kind of mission could be done by QML in a flash
    But QML is not an option before the desktop components release

    Thank you very much

    1 Reply Last reply
    0
    • Y Offline
      Y Offline
      Ymalaika
      wrote on last edited by
      #2

      You can install an event filter on the QPushButton, which will allow you to preview its mouse move events without the need to subclass. I typically do that when I need to do something like make menus or palettes fly out on hover.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DerManu
        wrote on last edited by
        #3

        Note that if mouse tracking (setMouseTracking) is off for the button, you will only receive mouse events when a mouse button is held down.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          stereomatching
          wrote on last edited by
          #4

          Thanks to both of you

          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