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. how to make the widgets display OK when put these widgets in a background image

how to make the widgets display OK when put these widgets in a background image

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 892 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.
  • L Offline
    L Offline
    leo.xucn
    wrote on last edited by
    #1

    Hi Guys:

    I am a beginner in Qt,

    I use Qt 5.7.1 in Linux, and I design the main window with a background image, then I put some labels and line text widgets in the main window,

    but the background image caused these widgets display not right, how i can make these widgets don't inherit from the main window? and display

    these widgets normally.

    regards!

    D 1 Reply Last reply
    0
    • L leo.xucn

      Hi Guys:

      I am a beginner in Qt,

      I use Qt 5.7.1 in Linux, and I design the main window with a background image, then I put some labels and line text widgets in the main window,

      but the background image caused these widgets display not right, how i can make these widgets don't inherit from the main window? and display

      these widgets normally.

      regards!

      D Offline
      D Offline
      Devopia53
      wrote on last edited by Devopia53
      #2

      @leo.xucn

      Hi.

      How did you implement it?
      If you use CSS, you must use a selector(QMainWindow).
      Like this:

      QMainWindow {
      background-image: url(:/background.jpg);
      }
      
      L 1 Reply Last reply
      1
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by VRonin
        #3

        give an object name name to the main window (it probably already has one if you are using designer) then use that name in the stylesheet. for example, if your main window's object name is MyMainWindow the style sheet will be something like:

        #MyMainWindow{
        background-image: url(:/logo.jpg);
        }
        

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        L 1 Reply Last reply
        1
        • D Devopia53

          @leo.xucn

          Hi.

          How did you implement it?
          If you use CSS, you must use a selector(QMainWindow).
          Like this:

          QMainWindow {
          background-image: url(:/background.jpg);
          }
          
          L Offline
          L Offline
          leo.xucn
          wrote on last edited by
          #4

          @Devopia53 Hi, I use designer, and set the stylesheet like this, background-image: url(:/logo.jpg);

          but the chid widgets still inherit from the main window,

          1 Reply Last reply
          0
          • VRoninV VRonin

            give an object name name to the main window (it probably already has one if you are using designer) then use that name in the stylesheet. for example, if your main window's object name is MyMainWindow the style sheet will be something like:

            #MyMainWindow{
            background-image: url(:/logo.jpg);
            }
            
            L Offline
            L Offline
            leo.xucn
            wrote on last edited by
            #5

            @VRonin Hi VRonin:

            I will try it.

            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