Seite 1 von 1

qtoolbutton textfarbe

Verfasst: 21. März 2006 15:21
von Esleborn
hi,
wie setz ich bei einem toolbutton, der eine QAction "verwendet", die Textfarbe?

Code: Alles auswählen

// Was in die Richtung tut nicht, bei ToolButons
   frp_button->setDefaultAction ( frp_action );

   QColor color;
   QPalette palette ( frp_button->palette ( ) );
   palette.setColor ( QPalette::ButtonText, color );
   palette.setColor ( QPalette::Text, color );
   palette.setColor ( QPalette::WindowText, color );
   palette.setColor ( QPalette::HighlightedText, color );
   frp_button->setPalette ( palette );
Thx

Elgrimm Esleborn

Verfasst: 21. März 2006 15:46
von macman
Das hier auch nicht:
btnButton->setPalette(QPalette(QColor(Qt::blue)));

Dann gibt es noch eins zu bedenken, wenn Du unter XP systemweit den XP-Style eingestellt hast, also diese Bonbonfarben, vor mir aus auch in silber, dann kannst Du nicht einzelnen Buttons andere Farben geben. Die Aussage des Trolltech Supports dazu:
Palettes are hints to the style about the colorscheme. Some styles
choose to ignore those thints, either because it would break the native
look'n'feel that a style provides, or simply because it's not possible
to respect the color.

With the Windows XP, both situations are the case - the XP style renders
buttons using the respective Win32 APIs provided by XP. There is no way
to change the color of a button. Setting a solid color would also break
the look - buttons in the XP style have s subtle gradient.

If you want to have control over the color scheme in your buttons, use
the classic style for those buttons. However, then you won't get the
XP-typical round edges either.

Verfasst: 21. März 2006 16:53
von Esleborn
ich benutzte aber den windows style nicht den Windowsxp style und es tut trotzdem nicht

Es tut aber auch nicht mit irgendeinem anderen Style

Verfasst: 22. März 2006 07:23
von macman
Hast Du es denn mal mit toolButton->setPalette(QPalette(QColor(Qt::blue))); probiert? Und sag nicht das geht nicht, ich hab es vorher getestet :-)

Verfasst: 22. März 2006 12:28
von Esleborn
boah ich bin so scheisse blöd... (sry für Worwahl)

ich benutze eine selbstgeschriebene Lib für die Transparenz der Buttons, und die erstellt eine neue Palette (klar)... wenn ich jetzt die Textfarbe einstell, nachdem er die Palette erstellt hat, ändere ich nichts mehr ;)... hab den Bug aus der lib rausgemacht und *tada* setPalette funktioniert mit Buttontext...
sry guys