Qt Forum

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

    Qt Academy Launch in California!

    Solved Fit BMP Splash to Screen

    Qt for Python
    qt for python python pyside
    1
    2
    169
    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.
    • M
      mullman1 last edited by

      Hello everybody,

      i have adjusted/written some code to show a splash image of a BMP file which has a fixed Size/Resolution.
      In my case it is 2248, 1383

      If i run my simple code i have attached, i get a splash of the bmp on my Monitor. But i want to fit the BMP to the monitor size.
      Do you think this is possible since the monitor is 1980x1080 and the BMP 2248x1383?
      I tried to find the specific QT modules but couldnt get anything running to fit/scale it to the window size.
      Does anyone know what i can do? And maybe give some code examples?

      BR

      Daniel

      import time
      import sys
      from PyQt6.QtWidgets import QApplication, QLabel, QSplashScreen
      from PyQt6.QtGui import QPixmap, QCursor
      from PyQt6.QtCore import Qt
      import os
      
      start_time = time.time()
      app = QApplication(sys.argv)
      total_loops = 1
      
      for i in range(total_loops):
      
          s = app.screens()[0] # Get the right screen
      
          # Display info about secondary screen
          print('Screen Name: {} Size: {}x{} Available geometry {}x{} '.format(s.name(), s.size().width(), s.size().height(), s.availableGeometry().width(), s.availableGeometry().height()))
      
          # Select desired image to be displayed
          pixmap = QPixmap('layer0000.bmp')
          print(pixmap.size()) # show pixmap size
      
          # Splash screen approach
          splash = QSplashScreen(pixmap)      # Set the splash screen to desired image
          splash.showFullScreen()             # Show the splash screen
          splash.windowHandle().setScreen(s)  # Set splash screen to secondary monitor
      
          time.sleep(2)
          end_time = time.time()
          print('Execution  time: ', end_time - start_time )
      
      sys.exit(app.exit())
      
      1 Reply Last reply Reply Quote 0
      • M
        mullman1 last edited by

        Okay. I found a solution myself by using the following command...
        Should be solved for now :D

        pixmap2 = pixmap.scaled(1920, 1080)

        1 Reply Last reply Reply Quote 0
        • M
          mullman1 last edited by

          Okay. I found a solution myself by using the following command...
          Should be solved for now :D

          pixmap2 = pixmap.scaled(1920, 1080)

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