Forum > QT

Qt App Style and Component Style


Maybe this is a dumb question, but I could not find any reference.

One of Qt's best feature is the styling of Application e.g. Motif, CDE, Windows, Platique etc. but more important than that is the ability to style components e.g.
QPushButton.SetStyle('font-size: 12px').

How is this achieved in Lazarus?, I mean the qt4.pas files has all the methods to support this? Is there a trick I can use styling in Qt-Laz?

The only resource on this subject I know is the following post on the Russian FPC forum:
It contains code examples so it does not require you to learn another language.

The author of this post gives three notes:
1. Qt stylesheet examples can be found at
2. Applying stylesheets to widgets does not work if no style has been applied to the form containing these widgets.
3. To make example code work you must change one line of code in qt4.pas unit from "procedure QApplication_setStyleSheet(handle: QApplicationH; ..." to "procedure QApplication_setStyleSheet(handle: QCoreApplicationH; ...".

@vvzh: you're completely wrong.QtLCL have full support for stylesheets per widget or general using by passing stylesheet via command line. You can apply stylesheet to any supported widget eg via TQtWidget(MyWinControl.Handle).StyleSheet property. I'm using it for a long time.
Sometimes you don't need to change anything in your qtlcl based app since any qt app can read stylesheet params crom command line eg. -stylesheet mystylesheet.txt
I'm using such scenario for touch screens where I need wider scrollbars and bigger buttons.

Thx for the info. Yes TQtWidget is what I was looking for, how about the app styles, is there a trick for it too.


[0] Message Index

Go to full version