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. Stylesheets
Forum Update on Monday, May 27th 2025

Stylesheets

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 962 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.
  • Steven_DAntonioS Offline
    Steven_DAntonioS Offline
    Steven_DAntonio
    wrote on last edited by
    #1

    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
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • Steven_DAntonioS Offline
        Steven_DAntonioS Offline
        Steven_DAntonio
        wrote on last edited by
        #3

        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
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by Chris Kawa
          #4

          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
          0

          • Login

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