Sorry, I don't get you. Can you rephrase your question?
Sorry, I don't get you. Can you rephrase your question?
Hi Lykurg...thanks for the reply...
Actually my class is as bellow (After applying the suggestion provided)
class MyClass: public QGraphicsView
{
....
widget1; //QPushbutton
....
widget2;//QTabWidget
....
void fun1()
{
//Some Functionality
}
void fun2()
{
//Some Functionality
}
protected:
void mousePressEvent(QMouseEvent * event)
{
QGraphicsView::mousePressEvent(event);
fun1();
fun2();
}
};
I have implemented "mousePressEvent" in my source code because I need it for some functionality. I have used
"QGraphicsView::mousePressEvent(event)" to get the functionality QPushbutton and QTabWidget, now when I press
the button in my application then I get the functionality related to the "QPushbutton and QTabWidget", but I
also get the remaining functionality of the mouse press event(As there is a call of fun1() and fun2()), Now I
want that when I press the QPushbutton then fun1() and fun2() should not process, Is there a way to ignore
event or some thing else???
Your question is still not very clear to me. Do you mean, you want func1() and func2() to execute when a user clicks within Graphics view but it also happening if you click on push button? What is the slot you have connected to push button click signal? Have you checked Event() method?
Hi manojmka...Thanks for the reply.
Yes I want func1() and func2() to execute when a user clicks within Graphics view but it also happening if I click on push button.
Actually I want that that when I click on the push button then func1() and func2() should not perform, The functionality I have implemented for pushbutton slot is working properly, but due to "mousePressEvent" both of the things are happening (pushbutton and mouspress).
Note: I have many objects in the graphicsview that are of the type of QPushButton. I am using signal mapper for that and those are working correctly.
Ok, I get your problem now. Following should be useful for you:
Qt Code:
{ if(!qApp->widgetAt(event->globalPos())->inherits("QPushButton")) { func1(); func2(); } }To copy to clipboard, switch view to plain text mode
I have not compiled this code, this is just for reference. Please do it as it fits your program.
Hi manojmka, thanks for the solution I have tried this solution as:
void MyClass::mousePressEvent(QMouseEvent * event)
{
if(!qApp->widgetAt(event->globalPos())->inherits("QPushButton"))
{
func1();
func2();
}
return QGraphicsView::mousePressEvent(event);
}
But unfortunately it doesn't work. While pressing on the "QPushButton" control is going to the if condition.
Note: I am using custom button hence I have used also:
void MyClass::mousePressEvent(QMouseEvent * event)
{
if(!qApp->widgetAt(event->globalPos())->inherits("MyButton"))
{
func1();
func2();
}
return QGraphicsView::mousePressEvent(event);
}
to achieve this. But it also doesn't work.![]()
Can you please try to check the event's global position and your widget's position for once? May be you have to use something else instead of event's global position.
Bookmarks