Recent

Author Topic: Qt App Style and Component Style  (Read 7850 times)

LA.Center

  • Full Member
  • ***
  • Posts: 244
    • LA.Center
Qt App Style and Component Style
« on: January 08, 2012, 11:07:24 am »
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?

vvzh

  • Jr. Member
  • **
  • Posts: 58
Re: Qt App Style and Component Style
« Reply #1 on: January 09, 2012, 09:42:09 am »
The only resource on this subject I know is the following post on the Russian FPC forum:
http://www.freepascal.ru/forum/viewtopic.php?f=5&t=6311&p=46571#p46571
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 http://doc.crossplatform.ru/qt/4.6.x/stylesheet-examples.html.
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; ...".

zeljko

  • Hero Member
  • *****
  • Posts: 1751
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Qt App Style and Component Style
« Reply #2 on: January 09, 2012, 12:49:43 pm »
@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.

LA.Center

  • Full Member
  • ***
  • Posts: 244
    • LA.Center
Re: Qt App Style and Component Style
« Reply #3 on: January 09, 2012, 09:46:38 pm »
Thx for the info. Yes TQtWidget is what I was looking for, how about the app styles, is there a trick for it too.

 

TinyPortal © 2005-2018