[Qt-interest] QMainWindow: Prevent mouse from leaving.

Martin Guillon MGuillon at movea.com
Wed Oct 28 16:08:03 CET 2009


Wow I didn’t know about the grab from the constructor. Will try it

Thanks a lot

-----Message d'origine-----
De : qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] De la part de R. Reucher
Envoyé : Tuesday, October 27, 2009 5:45 PM
À : qt-interest at trolltech.com
Objet : Re: [Qt-interest] QMainWindow: Prevent mouse from leaving.

On Tue, 27 Oct 2009 12:34:00 -0400, John McClurkin wrote:
> Set your application to run in full screen mode. This will also prevent
> viewing other parts of the desktop. It might be disturbing to a user to
> be unable to access applications that are on the desktop.
Yes...

I just tried this with grabMouse() / releaseMouse() and mouse-tracking... 
for me it simply works!

Just make sure to grab the mouse outside of your main-window's 
constructor.

--
MainWindow::MainWindow(QWidget *parent)
  : QMainWindow(parent)
{
  setupUi(this);

  // ...

  setMouseTracking(true);
  QTimer::singleShot(100, this, SLOT(delayedInit()));
}

MainWindow::~MainWindow()
{
  releaseMouse();
}

void MainWindow::delayedInit()
{
  grabMouse();
}
--

HTH, René
-- 
René Reucher
rene.reucher at batcom-it.net
http://www.batcom-it.net/
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list