Unsolved QSplitter::handle:pressed not working on external stylesheet
-
I am trying to change the background color when the user clicks and drags a QSplitter to adjust the size of a panel.
This style is in an external qss style sheet:QSplitter::handle:pressed { background: rgb(0, 176, 240); border: 2px solid rgb(0, 112, 192); }
This doesn't seem to work, nor has any variation that I have tried.
-
Hi and welcome to the forums
I fast tried your style and it seems to work on Windows.
What platform are you on ?
-
I'm on a VirtualBox RHEL 7 VM
-
@Robert-Sanson
So on Red hat 7, no effect is seen on the splitter?I assume it already uses fusion but depending on Qt version, could also be the gtk plugin.
Could you try
qApp->setStyle(QStyleFactory::create("Fusion"));
in main.cpp ?and see if that changes anything,
It can be that on linux, the QStyle used, does not support styling for that element.
-
@mrjj said in QSplitter::handle:pressed not working on external stylesheet:
qApp->setStyle(QStyleFactory::create("Fusion"));
I just tried that but it didn't make a difference. What is weird is that my other QSplitter styles seem to work, just not the ::handle:pressed one.
QSplitter { margin: 0; padding: 0; min-height: 6px; border: 1px solid rgb(210, 215, 211); } QSplitter:hover { margin: 0; padding: 0; min-height: 6px; border: 2px solid rgb(0, 176, 240); } QSplitter::handle:pressed { background-color: rgb(0, 176, 240); border: 2px solid rgb(0, 112, 192); }
-
Hi
I just tried in a Linux Mint and it also would color it when pressed.
What Qt are you using ?
Could be a bug in that version and RHEL 7. -
@mrjj RHEL version is 7.7 and Qt version is 5.14.1
-
@Robert-Sanson
Ok so not due being old version :)
I tried and older ubuntu and a mint and both worked.
But its using XFCE4REL 7 is using gnome or ?
sorry for my blondness but mostly used debian based linuxes. :)Would you say CentOS 7.7 would be the same ? ( to test on )
-
@mrjj Yea, I'm not sure. From searching it looks like CentOS would be similar.
-
@Robert-Sanson
yeah i also read it as very close to RHEL, at least from a system perspective.Btw could you try to tell me what
qDebug() << QApplication::style()->metaObject()->className();
(in main.cpp after QApplication is created)
says ? -
@mrjj said in QSplitter::handle:pressed not working on external stylesheet:
qDebug() << QApplication::style()->metaObject()->className();
Looks like it says QFusionStyle (without the previous code for setting it to that).
-
@Robert-Sanson
Ok that very odd then
as same style on the Mint Linux where it does color it.So can we talk about
"external stylesheet"in what way extern ?
im just setting it on the splitter with right click.Did you try in clean project ?
Just new default GUI project and place 2 buttons on MainWindow, then select both and right click and layout menu and apply splitter
then right click splitter (in widget tree to teh right) and Change stylesheet. -
Hi
Installed a CentOs and Qt but seems the gcc i get is 4.8.5
and i cant run anything. ( no c++ 11 it seems)
So didnt really found out more.Update.
I compiled a new GCC (7.3) and made it run.Oddly enough your stylesheet does work. !
-
I'm guessing it has something to do with my code instead of the style sheet (even though I find it weird that the hover works). Maybe its because I have overridden the mouse events.
What I mean about the external stylesheet is that the style sheet is in a file called MyStyleSheet.qss and gets read in by the program.
Thanks for the help.
-
@Robert-Sanson
Hi
loading it from file should really not matter.So yes, i think it mus tbe somthing in the code. But that easy to test with clean default GUI project :)
-
I've decided to sub class the QSplitterHandle and have overridden the mousePressEvent, mouseMoveEvent and mouseReleaseEvent. I did have the ::handle:pressed stylesheet pseudo-state working but now it has stopped working since I have overridden these functions. My assumption is that I need to set this pseudo-state of pressed to true, but I'm not sure how to get this working again. How would I go about doing this?
-
@Robert-Sanson
Hi
You must call base class version of mousePressEvent etc so
it can do its normal handling too.