Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Setting an image as the background of th UI

Setting an image as the background of th UI

Scheduled Pinned Locked Moved General and Desktop
6 Posts 5 Posters 5.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.
  • O Offline
    O Offline
    ommz
    wrote on last edited by
    #1

    I am trying to create an appealing UI by setting the background as an image using Qt Creator. Could someone please help me on the steps I am supposed to follow because I am stuck.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mkuettler
      wrote on last edited by
      #2

      You could set the background brush for the widget, doing something like this:
      @
      QPalette myPalette = palette();
      QBrush windowBrush = myPalette.window();
      windowBrush.setTexture( backGroundPixmap ); // use setTextureImage if the picture is a QImage
      myPalette.setBrush( QPalette::Window, windowBrush );
      @

      I did not test this code, so there maybe it does not work just like that. Let me know if you have problems with this.

      1 Reply Last reply
      0
      • O Offline
        O Offline
        ommz
        wrote on last edited by
        #3

        I dont think you git me right. I meant how do i set an image like a photo as the background of the UI?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DerManu
          wrote on last edited by
          #4

          [quote author="ommz" date="1338242420"]I dont think you git me right. I meant how do i set an image like a photo as the background of the UI?[/quote]

          Did you even try what mkuettler proposed? It sounds reasonable.

          Apart from that: No, a background image won't make any UI appealing, only cluttered and unprofessional. If that is your goal, go right ahead ;)

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sam
            wrote on last edited by
            #5

            You can also check "Embedded Styles Demonstration":http://doc.qt.nokia.com/4.7-snapshot/demos-embedded-styledemo.html example.

            1 Reply Last reply
            0
            • V Offline
              V Offline
              Vidhya
              wrote on last edited by
              #6

              Do set background image for a ui.
              you need to add resoucre file in the project's floder and add the resorce file name to the .pro file
              (

              RESOURCES +=
              resource.qrc
              )

              content of resource.qrc

              <RCC>
              <qresource prefix="/new/icon">
              <file>imagefilename</file>
              </qresource>
              </RCC>

              then go to the ui and select change style sheet

              add resource to it
              background-image: url(:/filepath);

              Regards,
              Vidhya

              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