[Qt-interest] Iaaue with mouseGrabber

nandita-a.mehta at nokia.com nandita-a.mehta at nokia.com
Mon Jul 25 13:28:55 CEST 2011


Hi
In my application i need to know which widget received the mouse click and for that I am using mouseGrabber().
However the application crashes.

To make it simple, in my Qt application I have a pushbutton; on its click a slot (hideWidget) is triggered.
In the slot, I am using mouseGrabber and then finding the widget name.
Can anyone explain why the app crashes?

My code is simple as follows:

// In ctor
connect (ui->pushButton, SIGNAL(clicked()), this, SLOT(hideWidget()));

// Slot
void MainWindow::hideWidget()
{

QWidget *wgt = QWidget::mouseGrabber();

QString str = wgt->objectName();
ui->label->setText(str);
}

Also I would like to cast "wgt" to QPushButton type.

Thanks.


Regards,
Nandita

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110725/0d0c2b44/attachment.html 


More information about the Qt-interest-old mailing list