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

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 903 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 20 Jan 2017, 05:43 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 20 Jan 2017, 06:03
    0
    • L leo.xucn
      20 Jan 2017, 05:43

      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 20 Jan 2017, 06:03 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 20 Jan 2017, 06:34
      1
      • V Offline
        V Offline
        VRonin
        wrote on 20 Jan 2017, 06:10 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 20 Jan 2017, 06:57
        1
        • D Devopia53
          20 Jan 2017, 06:03

          @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 20 Jan 2017, 06:34 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
          • V VRonin
            20 Jan 2017, 06:10

            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 20 Jan 2017, 06:57 last edited by
            #5

            @VRonin Hi VRonin:

            I will try it.

            1 Reply Last reply
            0

            4/5

            20 Jan 2017, 06:34

            • Login

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