PDA

View Full Version : Setting a Style Issue



forrestfsu
28th March 2007, 20:00
For my main program I set the style by doing something like this:


QApplication app(argc, argv);
app.setStyle(QStyleFactory::create("cleanlooks"));


Later on in one of my widgets, I make the widget push-pin-able. However, when the widget is placed in a new window it does not use the CleanLooks style...instead it uses the systems default style. How can I make it use the main applications style (CleanLooks)? Below is what I have attempted:


Qt::WindowFlags flags = Qt::Window;
flags |= Qt::WindowStaysOnTopHint;
setWindowFlags(flags);
this->setStyle(QStyleFacory::create("cleanlooks"));
setVisible(true);


Any pointers would be great.

Jimmy2775
28th March 2007, 20:59
Can you give a little more info, please? I'm not sure what you mean by "placing the widget in a new window". Is it still part of the same QApplication? Generally once you set the style for an application widgets will default to that style.

Are you able to get your widget to use the CleanLooks style when it's not in a new window? Or does the style not work at all for that widget?

forrestfsu
28th March 2007, 21:09
At first the push-pin widget is displayed within another widget (and does paint with the CleanLooks style). Example:



----------------------------
| Main Widget |
| ----------------- | // Both have Clean Looks Style
| | Push-Pin | |
| | Widget | |
| ----------------- |
| |
----------------------------


When I run the code shown below, the Push-Pin Widget displays in it's own window (which is what I want), however it no longer uses the CleanLooks style.


Qt::WindowFlags flags = Qt::Window;
flags |= Qt::WindowStaysOnTopHint;
setWindowFlags(flags);
this->setStyle(QStyleFacory::create("cleanlooks"));
setVisible(true);

----------------------------
| Main Widget | // Main Widget has CleanLooks Style
| | -----------------
| | | Push-Pin |
| | | Widget |
| | -----------------
| | // Push-Pin widget does not have CleanLooks
----------------------------


My goal is to get the Push-Pin Widget to always use the CleanLooks style.

Hope this clarifies

forrestfsu
28th March 2007, 21:21
Ahh...so frustrating. I just realized that this situation has nothing to do with the style. The style is being passed on to the Push-Pin Widget, however a coworker changed the Palette on the widget...so items displayed differently (and stupid me, I took that to be a sign of a different style). Thanks for all the help though...

Jimmy2775
28th March 2007, 21:25
No problem. Glad you got it resolved 'cause I was having a tough time figuring out what was going wrong there :)

forrestfsu
28th March 2007, 21:32
Ha, I'm glad also...thanks for looking into it for me.