Hide mouse pointer
On my embedded platform, I have to hide the mouse pointer in my app. To do that, I use @a.setOverrideCursor( QCursor( Qt::BlankCursor ) )@ at the very beginning of my app. It works well, but the cursor only disappears after I touch the screen once. As long as the touch panel is not touched, the mouse pointer remains visible.
Is there a way to make the pointer disappear without having to touch the panel first ?
andre last edited by
Sounds like your application does not have focus on startup.
My main looks like this :
@int main(int argc, char *argv)
QApplication a(argc, argv);
a.setOverrideCursor( QCursor( Qt::BlankCursor ) ); QPixmap pixmap ("/images/splash.bmp"); QSplashScreen *splash = new QSplashScreen(pixmap); QFont font("FreeSans", 48, QFont::Bold); splash->setFont(font); splash->show(); splash->showMessage(QObject::tr("Loading..."), Qt::AlignTop | Qt::AlignHCenter); StandardTerminal w; w.show(); QTimer::singleShot(500, splash, SLOT(close())); return a.exec();
I guess it should have focus, no ?
Add this to the start of your main() function but after you create the QApplication object:
QWSServer::setCursorVisible( false );
Ok, that works. Thanks !
Sorry for hijacking this old thread, but I have exactly the same problem and the solution posted doe not work for me. I am trying to have this on Qt4.3 on eLinux.
error: 'QWSServer' has not been declared
Are you using QWS? I can't recall when it was introduced. Have you tried adding #include <QWSServer> ?
Thanks a lot for your answer.
I start the application with -qws, I have not included QWSServer in my app.
No problem. Is it working now?
I (believe) I just got it working ... needs some more testing. I need the mouse events because there is a touch screen on (some of) the devices but I don't want to see the mouse cursor.
I have added -nomouse to the call ending with
/opt/bin/application -nomouse -qws -display directfb --dfb:mode=1280x800
Thanks anyway and have a nice (rest) of Sunday
Neil.W last edited by
I could be wrong, but the first thing to take focus in your code example is QSplashScreen, so calling setCursor on QSplashScreen, AND on the root widget would be required.
I had a program that worked fine until I added a splash screen, then I had the problem with the cursor until I realized that the splash screen was active some time before the main widget, and added setCursor in both places. Setting an override cursor on the app seemed to have no effect during the startup because the main loop in Qt has not started yet.
MhM93 last edited by
I know this post is really old but when I want to hide mouse pointer and do like this post said :
#ifdef Q_WS_QWS QWSServer::setCursorVisible( false ); #endif
then my device (Friendly ARM) touch does not work. but it works before that.
Now how can I restore the touch with pointer like before?