Stylesheets



  • Hi,

    I was reading up on the use of stylesheets for setting a background pic on a form. I am interested in trying this on the splash screen on my first project.

    I can't find a reference as to whether I need to include any precompile directives (#include things or anything like that)

    I want the pic to be only on the splash screen, the standard gray is fine for the actually working form.

    Other than some code like this is there anything special I need to do?

    QSplashscreen splash;
    splash.setStyleSheet("background-image:url(./file/left.png)");
    splash.show();

    Thanks,
    Steven


  • Moderators

    You don't need a stylesheet to set a splash screen image. QSplashScreen has a setPixmap method for that. Better yet - you can pass a pixmap directly in the constructor:

    #include <QSplashScreen>
    #include <QPixmap>
    
    ...
    
    QSplashScreen splash(QPixmap("./file/left.png"));
    splash.show();
    


  • Hi Chris,

    Thanks. That would be much easier. I'm looking specifically for a background image so I can write over it, but it might be better to just create a static pic with my writing on top of it (as part of the JPEG itself) and just include it as one pixmap as you suggest.


  • Moderators

    QSplashScreen has a showMessage method for writing text over the image. It's commonly used to display dynamic things like product version or a loading progress. Also QSplashScreen is just a widget like any other so you can override the paintEvent and overdraw whatever you want on it using QPainter.


Log in to reply
 

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