Hide mouse pointer
-
wrote on 12 Jul 2011, 08:00 last edited by
Hi,
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 ?Filip
-
wrote on 12 Jul 2011, 08:02 last edited by
Sounds like your application does not have focus on startup.
-
wrote on 12 Jul 2011, 08:19 last edited by
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 ?
-
wrote on 12 Jul 2011, 09:44 last edited by
Add this to the start of your main() function but after you create the QApplication object:
@
#ifdef Q_WS_QWS
QWSServer::setCursorVisible( false );
#endif
@ -
wrote on 12 Jul 2011, 10:05 last edited by
Ok, that works. Thanks !
-
wrote on 21 Oct 2012, 14:00 last edited by
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
Any ideas? -
wrote on 21 Oct 2012, 14:18 last edited by
Are you using QWS? I can't recall when it was introduced. Have you tried adding #include <QWSServer> ?
-
wrote on 21 Oct 2012, 14:37 last edited by
Thanks a lot for your answer.
I start the application with -qws, I have not included QWSServer in my app. -
wrote on 21 Oct 2012, 14:47 last edited by
No problem. Is it working now?
-
wrote on 21 Oct 2012, 14:52 last edited by
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=1280x800Thanks anyway and have a nice (rest) of Sunday
-
wrote on 16 May 2013, 21:40 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. -
wrote on 20 Oct 2016, 07:35 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?