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. Background image not visble
Forum Updated to NodeBB v4.3 + New Features

Background image not visble

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 2.3k 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.
  • G Offline
    G Offline
    GrahamL
    wrote on last edited by
    #1

    Hello
    I am trying to create am application where the main window shows a 'watermark' as the backgound
    Is this possible ?
    How would I go about it?

    Thanks

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Easiest might be to use a style sheet for that.

      1 Reply Last reply
      0
      • U Offline
        U Offline
        utcenter
        wrote on last edited by
        #3

        Or just reimplement the paint event, create a QBrush with the image and fill the widget rect() with it - it will pattern out nicely.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          GrahamL
          wrote on last edited by
          #4

          Thanks for the replies
          Both of these methods result in a tiled effect.
          What I want to achieve is have a single image

          How can I do that

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            You can control the repeating using the background-repeat style sheet property. Or you go utcenter's way of subclassing and just do your own rendering using QPainter::drawImage in the corner you want.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              GrahamL
              wrote on last edited by
              #6

              Hi
              I have set a background image on my main window by over riding the paintEvent.
              However, if I set the background color of the widget the image is no longer visible - what do I need to do in order to be able to set a background color and have a background image?

              Thanks

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                moderators note: I have merged your two topics. Please don't just start new topics on essentially the same issue.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  GrahamL
                  wrote on last edited by
                  #8

                  sorry, my apologies

                  1 Reply Last reply
                  0
                  • Chris KawaC Offline
                    Chris KawaC Offline
                    Chris Kawa
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    If you re-implement paintEvent you are responsible for painting everything yourself, including background color via something like QPainter::fillRect(). If you want to stick to the default color you can call QWidget::paintEvent() at the top of your reimplemented method and then paint over the image.

                    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