This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[SOLVED] Plasma::Label and different Qt styles

Tags: None
(comma "," separated)
User avatar
giucam
KDE Developer
Posts
62
Karma
1
OS
Hello all!

I use Arch Linux, with Qt 4.4.3 and Kde 4.1.82.
I'm doing a plasmoid and I have a problem with Plasma::Label.
I have a QGraphicsWidget in which there is a Plasma::Label. My Plasma::Applet has an instance of this widget. The problem is that if I change the style via systemsettings from Oxygen to whatever style the labels don't show anything.
I tried using a Plasma::Label directly in my Plasma::Applet, without the QGraphicsWidget layer, and in this way there is no problem.
But I need the QGraphicsWidget, and I can't really imagine where the problem could be, since I didn't put any code regarding the style nor Oxygen.
Does anyone have an idea?
Thank you all!!

Last edited by giucam on Wed Dec 17, 2008 2:59 pm, edited 1 time in total.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You probably need to connect the Plasma::Theme::themeChanged() signal to your own custom slot
Code: Select all
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT());

The Previewer applet in plasma-addons would probably be a good thing to read over. It uses a QGraphicsWidget with Plasma widgets on top. The code of interest is in the function setupOptionViewItem() in previewwidget.cpp


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
giucam
KDE Developer
Posts
62
Karma
1
OS
But what should i write in that slot? the problem is that it happens only with Plasma::Label, that isn't used in the preview plasmoid. I have an other QGraphicsWidget with some Plasma::IconWidget in, and that causes no problem.
And i can't understant what that line would solve, since the problem isn't with changing plasma themes, but kde styles such as Oxygen, Bespin, QtCurve and so on.
What's more the issue doesn't happen only when i change the style and the plasmoind is already running, but it happens even starting it after the change.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Your problem here is that Plasma widgets obey the Plasma theme, not the Qt theme. Text colors / background colors will never change if you change the Qt theme, as the colors come from the Qt theme.

In your case, it is not for the plasmoid developer to handle theming, it is for the theme developer.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
giucam
KDE Developer
Posts
62
Karma
1
OS
I think we don't understand each other.
The problem is that changing the Qt style my label shows no more its text or image.
I made a test plasmoid, with only my label. If I'm using Oxygen no problem, it shows the text I set using setText(QString), but if I use Bespin or whatever style the label shows anything. And i can't understand why, since, as you said, Plasma::Label listens to plasma themes and not to qt styles.
But if I put the Plasma::Label directly without putting my QGraphicsWidget between it and the Plasma::Applet it works correctly with all qt styles.
So I think this is a problem of my QGraphicsWidget, but I can't imagine what could be.[hr]
I found them!!

setFlag(QGraphicsItem::ItemClipsChildrenToShape);
static_cast(label->widget())->setWordWrap(false);

these two lines are the ones that make all disappeare!
Now i only have to understand why!

Last edited by giucam on Tue Dec 16, 2008 4:29 pm, edited 1 time in total.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
glad to hear you managed to find a solution. If your problem is indeed solved, could you please add [SOLVED] to the beginning of the thread subject? Thanks in advance

PS: any hope for a link to this plasmoid your developing? ( My quiz one is here)


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
giucam
KDE Developer
Posts
62
Karma
1
OS
well, the problem is only partially solved, because i need these two lines for my plasmoid to work correctly so i need to find an alternative or a way to make them work correctly.

p.s. my plasmoid is playwolf[hr]
I just noticed that i were partially wrong. only one of the two lines i wrote causes the problem:
setFlag(QGraphicsItem::ItemClipsChildrenToShape);

But now i think tis is a bug of Plasma::Label bacause i tried, for example, Plasma::IconWidget and it is show even in a QGraphicsWidget with that flag set.[hr]
I found this page on the bug tracker of Qt. So it is a Qt bug, and for now i solved with

Plasma::Label->nativeWidget()->setAttribute( Qt::WA_NoSystemBackground, false );

Last edited by giucam on Wed Dec 17, 2008 3:01 pm, edited 1 time in total.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell