PDA

View Full Version : How to disable Mouse pointers on particular QWidget



rajeshs
30th June 2007, 10:17
Hi all,

Now i am using QT 4.2 , I want to disable mouse action when mouse pointer moves to particular Widget, and when it moves to another widget it should be enabled,

If anybody knows please help me.

Thanks
Rajesh.S

jpn
30th June 2007, 13:31
What is "mouse action"? Perhaps you could disable (http://doc.trolltech.com/4.3/qwidget.html#setDisabled) the widget?

Gopala Krishna
30th June 2007, 18:23
Hi all,

Now i am using QT 4.2 , I want to disable mouse action when mouse pointer moves to particular Widget, and when it moves to another widget it should be enabled,

If anybody knows please help me.

Thanks
Rajesh.S

I guess there are no direct method to do. Probably you create your own cursor which is blank and set for the widget. This sounds crude but anyway try this. You might need to ignore all the mouse events if you dont want the widget to be disabled.

#include <QtGui>

class Widget : public QWidget
{
public:
Widget(QWidget *par=0) : QWidget(par)
{
QBitmap bitmap(32,32);
bitmap.fill(Qt::color0);//initialize every thing to 0 bit
QCursor cursor(bitmap,bitmap);//blank cursor
setCursor(cursor);
}

bool event
};

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Widget w;
w.show();
return app.exec();
}

rajeshs
1st July 2007, 13:46
Thak you For your Replies,

I got another direct solution, we can use like following ,

int main(int argc,char *argv[])
{
QApplication app(argc,argv);
QMainWindow* wid=new QMainWindow;
app.setOverrideCursor(Qt::BlankCursor);
wid->show();
return app.exec();
}
Thanks,
Rajesh.S

Gopala Krishna
1st July 2007, 17:05
app.setOverrideCursor(Qt::BlankCursor);


lol. Never thought of searching for it after going through some unneeded cursors in the predefined cursor list. :eek:
Good that you found out a more elegant solution. :)