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】let QTabWidget show the corresponding page when mouse cursor hover on the tab I want to show the corresponding page when mouse cursor hover

【Solved】let QTabWidget show the corresponding page when mouse cursor hover on the tab I want to show the corresponding page when mouse cursor hover

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.5k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    redstoneleo
    wrote on last edited by
    #1

    let QTabWidget show the corresponding page when mouse cursor hover on the tab

    I want to show the corresponding page when mouse cursor hover on the tab of a QTabWidget.
    !http://oi43.tinypic.com/2d7sqpf.jpg(http://oi43.tinypic.com/2d7sqpf.jpg)!
    For example ,when the mouse cursor hover on tab ‘page2’ here , I hope the QTabWidget show the corresponding page automatically instead of clicking,so how to implement this feature ?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Just a quick idea: subclass QTabBar and react to the QHoverEvent then subclass QTabWidget to use your custom QTabBar

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        redstoneleo
        wrote on last edited by redstoneleo
        #3

        [quote author="SGaist" date="1374267167"]Hi,

        Just a quick idea: subclass QTabBar and react to the QHoverEvent then subclass QTabWidget to use your custom QTabBar

        Hope it helps[/quote]

        I implement in this way

            def mouseHoverOnTabBar(self):
                self.tabBar=self.tabWidget.tabBar()
                self.tabBar.setMouseTracking(True)
                self.tabBar.installEventFilter(self)
        
            def eventFilter(self, obj, event):
                if obj == self.tabBar:
                    if event.type() == QEvent.MouseMove:
                        index=self.tabBar.tabAt(event.pos())
                        self.tabBar.setCurrentIndex (index)
                        return True
                return super().eventFilter(obj, event)
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Right, didn't thought of the eventFilter... Good one !

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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