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. Cannot set an image background in a Button (qt quick controls)
Forum Updated to NodeBB v4.3 + New Features

Cannot set an image background in a Button (qt quick controls)

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.9k 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.
  • M Offline
    M Offline
    mikecurl91
    wrote on last edited by
    #1

    In a qt qml quick project, I've this code:

    @import QtQuick 2.1
    import QtQuick.Controls 1.0
    import QtQuick.Layouts 1.0@
    .... ..... ....
    @Button {
    id: button1
    x: 160
    y: 130
    width: 50
    height: 50
    text: ""
    iconSource: "../../img/up.png"
    }@

    Compiling, there are no errors or warnings, but the button have no image in background!
    Image for the background is 32x32 Png format.
    Why it does'no work?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jens
      wrote on last edited by
      #2

      This should work fine but I believe we have added a bug fix to the base style (i.e not platform specific style in 5.1.1). If you are using QGuiApplication and not QApplication, that would be the most likely reason you are not seeing the icon right now.

      To work around it, you might simply add an Image as a child of the button, or you can override the label component in a ButtonStyle.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mikecurl91
        wrote on last edited by
        #3

        Thank you, I've work around it with the Image child solution
        ;)

        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