Question

I have a splash screen image that I display with splash.showFullScreen() but it doesn't re size it to the screen resolution so it either comes out tiled or to large depending on the display. I have tried everything I can think of but nothing works. This might sound like a stupid question which it probably is but I can't find the answer so if any can just help me with this? If it makes a difference I use a QPixmap named pixmap for the splash image. By the way I want the image to be stretched to the screen resolution.

Was it helpful?

Solution

You should scale the pixmap to the size of the screen with QPixmap::scaled(). You can get the screen resolution by calling QDesktopWidget::screenGeometry(). The desktop widget can be obtained by 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);

(I'm sorry, I can not check this, because I do not have a development environment on this computer... I hope it is correct.)

OTHER TIPS

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top