PDA

View Full Version : How to disable mouse click over a QSplashScreen



graciano
23rd October 2009, 18:32
Hi,
This example show me a splash screen for 5 seconds, an then the main window.


#include <QtGui/QApplication>
#include "mainwindow.h"
#include <QSplashScreen>
#include <QTimer>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QSplashScreen *splash = new QSplashScreen;
splash->setPixmap(QPixmap("f0.png"));
splash->show();
splash->showMessage(QObject::trUtf8("A preparar a janela principal ..."), Qt::AlignRight|Qt::AlignTop, Qt::black);
MainWindow w;
QTimer::singleShot(5000, splash, SLOT(close()));
QTimer::singleShot(5000, &w, SLOT(show()));
return a.exec();
}


During those 5 secs if i click on the QSplassScreen i have "nothing" until the main window shows up.

Can i disable the possibiliti of clicking on the splashscreen?

Thanks

wagmare
23rd October 2009, 18:36
use eventFilter
bool QObject::eventFilter ( QObject * watched, QEvent * event ) [virtual]

and disable the mouse click event ..

graciano
8th November 2009, 17:02
Hi,
I did something like this:



#include "mysplash.h"

mySplash::mySplash(QWidget *parent)
:QSplashScreen(parent)
{
this->installEventFilter(this);
}

bool mySplash::eventFilter(QObject *target, QEvent *event){
return true;
}


Now it filters EVERYTHING right?
Nothing can kill mySplash :cool: