PDA

View Full Version : QSplash screen at the baskground



raghvendramisra
7th February 2008, 11:26
Hi i have an application in which i am displaying a splash screen on clicking a button.
but the splash screen is displayed at the background of the form.

Where can be the problem??????????

Regards

Raghvendra

wysota
7th February 2008, 11:33
In the code you use :)

And seriously, can you paste some of it? :)

ashukla
7th February 2008, 12:04
#include <QApplication>

#include <QSplashScreen>

#include <QWidget>



int main(int argc, char *argv[])

{

QApplication app(argc, argv);



QPixmap pixmap;

pixmap.load(":/images/splash.png");

QSplashScreen *splash=new QSplashScreen(pixmap);

splash->show();


QWidget w;

app.processEvents();

w.show();


splash->finish(&w);

delete splash;

return app.exec();

}

hope its help.

przemoc
7th February 2008, 15:42
Using QSplashScreen usually involves setting Qt::WindowFlags, namely Qt::WindowStaysOnTopHint to get desired result.

I'd changed fragment of your code as follows:


int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPixmap pixmap(":/images/splash.png");
QSplashScreen splash(pixmap, Qt::WindowStaysOnTopHint);
splash.show();
app.processEvents();
// (...)
splash.finish(&w);
return app.exec();
}

przemoc
8th February 2008, 00:48
Sorry, I didn't spot earlier, that this topic is related to Qt3. In this case, you probably should use Qt::WStyle_StaysOnTop (http://doc.trolltech.com/3.3/qt.html#WidgetFlags-enum). There is also Qt::WStyle_Splash (http://doc.trolltech.com/3.3/qt.html#WidgetFlags-enum), maybe it'll be sufficient for you.

raghvendramisra
8th February 2008, 07:02
Hi ,
I tried with the "WStyle_StaysOnTop" flag but still my flash screen is in the back ground.

I am pasting a piece of my code.
In my application when i am clicking the ok button the function below is called and shall display Splash Screen on top.


void Form2::onOk()
{

QPixmap pixmap("splash.png");

QSplashScreen *splash = new QSplashScreen(pixmap,Qt::WStyle_StaysOnTop);
splash->show();

splash->message(QObject::tr("Setting up the main window..."),
Qt::AlignRight | Qt::AlignTop, Qt::white);

delete splash;

}

Plz tell me how to solve the problem.

Regards
Raghvendra

wysota
8th February 2008, 10:18
Are you deleting the splash screen right after creating it?

raghvendramisra
8th February 2008, 11:02
Actually i am creating bthe Splash screen , writting the message to it and then deleting the splash.
The splash screen comes and displays the message also but it comes at the background of the widget from where i am calling it.

So to see that i have to minimize my widget every time i call it.
hope i am clear with the problem................

wysota
8th February 2008, 11:37
Here is my working code for a splashscreen:

QPixmap splashpixmap(settings.appPath() + "/icons/splashskrin.png");
QSplashScreen *splash = new QSplashScreen( splashpixmap );
splash->show();
splash->message( QObject::tr("Loading bitmaps..."), Qt::AlignHCenter|Qt::AlignVCenter );
a.processEvents();
createMimeFactory();
editor *mw= new editor();
splash->message( QObject::tr("Loading plugins..."), Qt::AlignHCenter|Qt::AlignVCenter );
a.processEvents();
QString plugspath(settings.appPath()+"/plugins/");
plugins.load(plugspath);
plugins.addIOFormat((void*)newSTL, "STL");
splash->message( QObject::tr("Setting application..."), Qt::AlignHCenter|Qt::AlignVCenter );
a.processEvents();
splash->finish(mw);
splash->deleteLater();

przemoc
8th February 2008, 12:15
Hi ,
I tried with the "WStyle_StaysOnTop" flag but still my flash screen is in the back ground.

If changing line with deleting splash immediately after creating don't help you, you can try adding flag WX11BypassWM (http://doc.trolltech.com/3.3/qt.html#WidgetFlags-enum) as documentation suggests, necessity of putting this flag depends on WM you use, so I presume it is better to always have it.
Did you try also Qt::WStyle_Splash (http://doc.trolltech.com/3.3/qt.html#WidgetFlags-enum)? If your WM doesn't support NETWM (http://blackboxwm.sourceforge.net/NetWM), than mentioned earlier WX11BypassWM (http://doc.trolltech.com/3.3/qt.html#WidgetFlags-enum) flag is used.

raghvendramisra
9th February 2008, 04:38
HI,
thanx everyone my problem is solved now.
i have used raise() to bring it to the top and it is working now..........

Regards