Custom ComboBoxStyle on Android (Qml)
-
Hey,
When I use a ComboBox on android, it gets a native style like expected. When I try to customize the style (like this):
ComboBox { ... style: ComboxBoxStyle {} }
The combox box is styled as if it would be on desktop (even so I did not specify anything).
Could it be, that the ComboBoxStyle I am creating this way is the wrong one (for android)? How can I get the platform specific style and customize that?
-
It's a fallback. Example on an app I've been working on. It will also change to a completely different look and feel if you use
Not explicitly explained in the documentation(took me a while to realize it) , using different QApplication classes will alter the default style used.
#define QuickApp QApplication (part of Widgets module, provides mostly platform/desktop styles)
#else
#define QuickApp QGuiApplication (provides default style chosen by Qt)style: ButtonStyle { background: Rectangle { id: csBG color: control.pressed ? "black" : "#142147" states: [ State { name: "csfShow" PropertyChanges { target: csBG color: "black" } }, State { name: "fakeHideOut" PropertyChanges { target: csBG color: "#142147" } } ]
If you take a look at http://doc.qt.io/qt-5/qml-qtquick-controls-styles-comboboxstyle.html
You will notice that in properties we have
background
which takes in a Component (Item, Rectangle, etc).font
will take care of anything related to fonts but doesn't limit you in any way.Point is you can override anything you like, if you leave any of the properties empty it will use pre-determined fallback as far as I remember.
You may be interested in this article http://blog.qt.io/blog/2015/11/23/qt-quick-controls-re-engineered-status-update/ (coming in 5.6 which should be out either this or next month)