PDA

View Full Version : Splash screen with multiple lines of custom text.



cmp1104
29th May 2013, 16:47
I am using Qt 4.7. At the start of my application I display a splash screen with general information about the program and related project. The information I want to display will occasionally need to change (version numbers and such). I would like to find a simple way of updating this text.

I started with just displaying the splash screen graphic without any version number information. This works fine. I then followed this example (http://qt-project.org/wiki/Custom_splashscreen_with_text) to display the screen with custom text at a certain position on top of the graphic. This also worked fine. The issue is when I want to have multiple sets of custom text. I am pretty sure that every time the screen is updated with a new line of text the previous line of text is lost in the update. (For example I try to display three different sets of text and I only see the third set of text.)

Any thoughts?

Thanks.

Santosh Reddy
29th May 2013, 16:59
The issue is when I want to have multiple sets of custom text.
It is not possible to have multiple line with that example.

Try this work around, set a message with all three line as a single string with line breaks "\n".

cmp1104
29th May 2013, 20:08
Good thought on the use of \n. I had tried that previously and it works okay though it limits your positioning choices.

The only workaround I have come up with so far is to modify the "drawContents" function used in the example. Instead of calling "drawText" once, I call it three times:

void cCustomGraphics::drawContents(QPainter* pPainter)
{
QPixmap textPix = QSplashScreen::pixmap();
pPainter->setPen(this->color);
pPainter->drawText(this->rect, this->alignment, this->message);
pPainter->drawText(QRect::QRect(75,337,400, 30), this->alignment, "0.1");
pPainter->drawText(QRect::QRect(128,372,400, 30), this->alignment, "May 29, 2013");
}

This seems to work okay.