Qt screen resolution screen screen

I have an image with a splash screen that I show using splash.showFullScreen (), but it does not change it to the screen resolution, so it either comes out of tiled or large depending on the display. I tried everything I could, but nothing works. This may seem like a silly question, which probably is, but I can't find the answer, so if anyone can help me with this? If that matters, I use a QPixmap named pixmap for the splash image. By the way, I want the image to stretch to screen resolution.

+4
source share
3 answers

You must scale pixmap to screen size using QPixmap :: scaled () . You can get the screen resolution by calling QDesktopWidget :: screenGeometry () . The desktop widget is available from QApplication :: desktop () .

You can try something like this:

QDesktopWidget* desktopWidget = qApp->desktop(); QRect screenGeometry = desktopWidget->screenGeometry(); int screenWidth = screenGeometry.width(); int screenHeight = screenGeometry.height(); QPixmap pixmapForSplash = yourPixmap.scaled(screenWidth, screenHeight); QSplashScreen splashScreen(pixmapForSplash); 

(Sorry, I cannot verify this because I do not have a development environment on this computer ... I hope this is correct.)

+8
source

I think you should call the resize() method for your splash screen to fit the available desktop geometry, which you can use with QDesktopWidget::availableGeometry . The QApplication::desktop() function is used to get an instance of QDesktopWidget . slpashScreen.resize(QApplication::desktop()->avaiableGeometry().size());

+2
source

If you use QLabel to display an image, make sure that the label is in the layout that will make it fill the entire parent widget and set the label to scale its contents with setScaledContents (true) .

+1
source

Source: https://habr.com/ru/post/1382016/


All Articles