Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Stylesheets

    General and Desktop
    2
    4
    712
    Loading More Posts
    • 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.
    • Steven_DAntonio
      Steven_DAntonio last edited by

      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

      1 Reply Last reply Reply Quote 0
      • Chris Kawa
        Chris Kawa Moderators last edited by

        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();
        
        1 Reply Last reply Reply Quote 0
        • Steven_DAntonio
          Steven_DAntonio last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • Chris Kawa
            Chris Kawa Moderators last edited by Chris Kawa

            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.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post