QFrame with layout and comboBoxes insight => setStylesSheet calls index method of QAbstractItemModel of connected comboBoxes
-
Hi,
Can you provide a minimal compilable example that shows that behaviour ?
-
Creating an example is rather time intensive, thus I do not want to do it now. My question was more about the general understanding, when the index and data method of QAbstractItemModels are called. I expected that this will happen only when you interact directly with the corresponding ComboBox/Listview. But obviously, this happens on much more situations. How to figure out what signals or evants will interact with the model.
By the way, I am working with PyQt.
Does this help a bit more?
Daniel -
AFAIK, PyQt should have no impact on that.
The high number of calls are indeed pretty surprising. What might happen is that there are several changes of sizes due to the change of style sheet. Not knowing how many combo boxes you have and what your GUI looks like, it's pretty much impossible to guess what is happening.
-
Hey, sorry for my late reply.
I also thought already that it might be because of the size change. So I tried already to keep the border width constant at 3px. However, just setting border-color in the style sheet does not have an effect (see last code snippet). I have to use the border property where I have to set the width, style and color. So I always have to set a new width and maybe even if I always keep 3px, it resets the with and recalculates the size of the content inside the frame.on enter event I use (CardInnerFrame is the name of the class I use. It is a subclass of QFrame)
self.setStyleSheet("CardInnerFrame {" "border: 3px solid rgb(85,142,213);}")
on leave I use:
self.setStyleSheet("CardInnerFrame {" "border: 3px solid rgb(160,160,160);}")
I would prefer to use to set only the color:
self.setStyleSheet("CardInnerFrame {" "border-color: rgb(160,160,160);}")
But that one has no effect.
Thanks for your help.
Daniel -
-
Hi
If you suspect its due to stylesheet usage, you see this performance drop, why
not just paint the effect yourself in paintEvent since u already subclassed the frame.
it is very little codeQStyleOptionFrame opt; initStyleOption(&opt); style()->drawControl(QStyle::CE_ShapedFrame, &opt, p, this);
-
@mrjj Sorry that I did not answer for so long. Was totally busy with other important stuff that I could not further focus on this. But now I am back on this topic. I like the idea to simply paint it on my own. But actually I am a little bit over-strained with it. I never painted something on my own before, but I would really like to learn it.
So, here is what I want to achieve. When I enter the frame, the grey frame should get blue plus I want to change the line width of the frame.
What I have: A Class that subclasses the Qframe class where I reimplemented the enterEvent method, to catch the the events, when the mouse pointer enters the frame. What to do now? Creating a painter from QtGui.QPainter? The few lines you added did not help so much.
I am using Qt for python, but I guess it will be more or less the same as in normal Qt, right? I appreciate your help.
Daniel
-
@Dagginio
Hi
Using python should be exactly the same.
So in enterEvent you set a variable to know mouse has enter and clear
it on the leave event.
Then you override paintEvent
and there you make a QPainter and draw the frames the way you want.(example) disclaimer. not a pyt user :)
def paintEvent(self, event): painter = QPainter(self) painter.drawLine(0, 10, 10, 10)
-
@mrjj thanks. That is what I was thinking of. However, when set a variable that the mouse entered, it will not trigger the painting itself. Is a event function callable? Can I call the paintEvent method from the enterEvent method? And assuming I painted already a blue frame. Do I have to remove that blue frame before I paint a grey one?
Daniel
-
@Dagginio
Hi
just call update() to have it refresh when "status" changes.-Do I have to remove that blue frame before I paint a grey one?
depends if you have autofillbackground on widget on.
in that case it will be cleared default.
else u might have to. try without and see