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



  • 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!



  • @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);
    }
    


  • 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);
    }
    


  • @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,



  • @VRonin Hi VRonin:

    I will try it.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.