Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
I have an odd issue that my SplitHCursor is invisible on my QSplitter(s).
I'm trying to understand the reproducing pattern, but no luck so far.
One quick question is what property is responsible for changing the mouse cursor on QSplitter?
Do I need to set stylesheet or something in QSplitter??
Thanks in advance for your help.
@ShinSat QSplitter itself works but no SplitHCursor... Strange..
What version of Qt are you using ?
On what platform ?
Can you show the code setting up the QSplitter ?
Thanks for an update, @SGaist
I'm using pyqt5.9.1 on Windows7.
Still investigating the issue and found in a different app that SplitHCursor was also invisible occasionally in horizontal header in my QTable/QTreeView on QSplitter.
I wonder if there's workaround to forcefully set the mouse cursor shape..
I'll share code snippet once it's ready.
@ShinSat I'm still investigating the issue with the following custom QSplitter/QSplitterHandle.
One strange thing is that I can't change the cursor shape in MySplitterHandle.mouseMoveEvent.
MySplitterHandle.mouseMoveEvent is successfully invoked but the cursor shape doesn't change.
Is there any possible situation where setCursor method doesn't work?? What am I missing???
class MySplitter(QSplitter): def __init__(self, dir, parent=None): super(MySplitter, self).__init__(parent=parent) self.setOrientation(dir) #self.setHandleWidth(1) self.split_handle = None def createHandle(self): self.split_handle = MySplitterHandle(self.orientation(), self) return self.split_handle class MySplitterHandle(QSplitterHandle): def __init__(self, orientation, parent): super(MySplitterHandle, self).__init__(orientation, parent) self.setCursor(Qt.SplitHCursor if orientation == Qt.Horizontal else Qt.SplitVCursor) #self.setCursor(Qt.PointingHandCursor) self.setMouseTracking(True) self.direction = orientation def mouseMoveEvent(self, event): print('setting splitter cursor') super().mouseMoveEvent(event) #self.unsetCursor() self.setCursor(Qt.SplitHCursor if self.direction == Qt.Horizontal else Qt.SplitVCursor)
Looks like self.cursor().shape() in MySplitterHandle shows the correct shape but the mouse cursor is not changing..
@ShinSat Found one workaround with the following code, but my widgets are on QMainWindow and another splitter between QDock and CentralWidget is also staying ArrowCursor, which should be either SplitHCursor or SplitVCursor. Therefore, the workaround can't be the final solution.
class MySplitterHandle(QSplitterHandle): ... ... def enterEvent(self, e): print('enterEvent') #super().enterEvent(e) QApplication.setOverrideCursor(Qt.SplitHCursor if self.direction == Qt.Horizontal else Qt.SplitVCursor) def leaveEvent(self, e): print('leaveEvent') #super().enterEvent(e) QApplication.setOverrideCursor(Qt.ArrowCursor)
@ShinSat SOLVED. It was my fault that I was missing QApplication.restoreOverrideCursor() after some modification of cursor shape.
@ShinSat Sorry, again. I just wanted to share what are the options that we can change the mouse cursor shape.
Is this the only option that we have?
These are for application wide modification otherwise you have QWidget::setCursor.
@SGaist Ah, yes, I was missing that... ashamed....
Thank you very much for your help!