PDA

View Full Version : QWidget refuses to accept it's own font, insists on inheriting



Mookie
12th January 2011, 19:57
I have a QWidget that initially had no parent (i.e. top level window). It defined it's own pallete and fonts.

I decided that I wanted to take advantage of the parent/child cleanup if the main application was destroyed. So I gave this window a parent in it's initializer list and add the following to the constructor.


setWindowFlags(windowFlags() | Qt::Window); // top-level window
I can set a pallete but this window it refusing to accept a new font. If I again remove the parenting then it takes the font.

Ideas?

I initially thought that maybe my style sheets or my custom style were interfering, but I disabled both and the problem persists.

wysota
12th January 2011, 21:20
Can you prepare a minimal compilable example reproducing the problem?

Mookie
19th January 2011, 19:33
I had already tried, but my stripped down version behaved correctly.

I eventually found out that it was, indeed, a style sheets issue after all. I had a style sheet defined at a much higher level that was clobbering the look. My new best-coding practice is to use setStyleSheet() judiciously and only when the desired effect cannot be easily achieved through palettes.

wysota
19th January 2011, 19:43
My new best-coding practice is to use setStyleSheet() judiciously and only when the desired effect cannot be easily achieved through palettes.
That's a very good approach.