Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [solved] QML Button Element - how to change background color?

[solved] QML Button Element - how to change background color?

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 14.9k Views
  • 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.
  • U Offline
    U Offline
    uruselfei
    wrote on 9 Dec 2011, 22:14 last edited by
    #1

    hello!

    i'm using standard Button Element and i need to change background color to something else than usual or inverted. let's say, how to change button color to green or red?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      markc
      wrote on 9 Dec 2011, 23:32 last edited by
      #2

      I'm not sure which "standard Button Element" you mean but if a Rectangle includes a MouseArea with an "id: ma" then something like this works to alternate the background when clicked...

      @gradient: Gradient {
      GradientStop { position: 0.0; color: ma.pressed ? "#0F0F0F" : "#2F2F2F" }
      GradientStop { position: 1.0; color: ma.pressed ? "#2F2F2F" : "#0F0F0F" }
      }@

      1 Reply Last reply
      0
      • U Offline
        U Offline
        uruselfei
        wrote on 10 Dec 2011, 07:11 last edited by
        #3

        I mean button element from qt-components http://doc.qt.nokia.com/qt-components-symbian/qml-button.html

        Button built on rectangle is not an option, unfortunately

        1 Reply Last reply
        0
        • T Offline
          T Offline
          task_struct
          wrote on 10 Dec 2011, 07:41 last edited by
          #4

          Hello,

          Button element uses a BorderImage, not a Rectangle with gradient( http://qt.gitorious.org/qt-components/qt-components/blobs/master/src/symbian/Button.qml ). So I think it is not possible to change color.

          "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

          • Linu...
          1 Reply Last reply
          0
          • U Offline
            U Offline
            uruselfei
            wrote on 10 Dec 2011, 08:25 last edited by
            #5

            eventually found solution!

            @
            Button {
            // ... some needed design stuff
            platformStyle: ButtonStyle {
            background: "image://theme/color18-meegotouch-button-accent-background"
            pressedBackground: "image://theme/color18-meegotouch-button-accent-background-pressed"
            }
            }
            @

            it is also possible to make theme and other properties dynamically defined, but for me it was eniugh to have hardcoded value.

            some more reading is here: http://harmattan-dev.nokia.com/docs/library/html/qt-components/qt-components-meego-buttonstyle.html

            1 Reply Last reply
            0

            1/5

            9 Dec 2011, 22:14

            • Login

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