Qt Designer image background



  • Hello
    I try to put an image as a background of my GUI with change style sheet, the problem it will affects all widgets on the form giving them the same background. Is there an option to set up only the background form?

    Thank you for your help

    Massi



  • another thing is when I run the application it doesn't show me my background image



  • post here the contents of qss file



  • Hi, I found a way to fix it but I'm not sure if it's correct or not.
    First, I started by adding a new Qt Resource in the way to get .qrc file. Immediately, in my Qt designer, I added some JPEG images in this new resource.
    I'm learning day by day Qt, so I'm not familiar with it and particularly with qss file. In my edit style sheet, I wrote:
    @
    #ImageCoregistration{
    background-image: url(:/Image/for-business-backgrounds-wallpapers.jpg);
    }
    @
    ImageCoregistration is the name's form.

    Another problem appears when I change the color of any widget like a tabWidget by selecting the color with palette property. It still does nothing when I launch the application? do I need to specify it in the edit style sheet?

    best regards!

    Massi



  • Try to use resource file in same directory.Before using this file,you can mention your image file name.
    File Format is resource.qrc
    @
    <RCC>
    <qresource prefix="/images">
    <file>Images/Disk.png</file>
    </qresource>
    </RCC>
    @

    [Edit: Added @ tags around code; mlong]



  • Thank you it works!! by the way do you know how to set QTabWidget (tab) transparent, same as the image background because I'm struggling to find how to do it. I have tried too many way to code it but at the end I always got a white background.
    in the qss:
    @
    form.widget.tab->setStyleSheet("background-color: rgba( 255, 255, 255, 0% );" );
    form.widget.tab->setStyleSheet("background: transparent;" );
    In the main menu I have tried this (ImageCoregistration is the name's form)
    ImageCoregistration form;
    QPalette palette = form.widget.tab->palette();
    palette.setBrush(QPalette::Base, Qt::transparent);
    form.widget.tab->setPalette(palette);
    form.widget.tab->setAttribute(Qt::WA_OpaquePaintEvent, false);
    @
    It does nothing!!
    Thank you for your reply

    Massi

    [Edit: @ tags; mlong]


  • Moderators

    When posting code snippets, please wrap them in @ tags. Thanks.


Log in to reply
 

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