Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Custom ComboBoxStyle on Android (Qml)
Forum Updated to NodeBB v4.3 + New Features

Custom ComboBoxStyle on Android (Qml)

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RudolfVonKrugstein
    wrote on last edited by RudolfVonKrugstein
    #1

    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?

    1 Reply Last reply
    0
    • David.GD Offline
      David.GD Offline
      David.G
      wrote on last edited by
      #2

      Hey @RudolfVonKrugstein

      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)

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved