I would like to connect to a widget's signal. When signal is emitted I need to do some processing and then envoke the orignal slot to which this signal was connected in the first place.
So, if the widget is a button I have a wrapper like the one below. My questions are in the comments. And the general question - is that approach correct at all? May be there is something else already provided by Qt?
class objBtnHook
{
public:
{
// how to store connected slot that is currently connected to the "clicked" signal?
QObject::disconnect (btn,
SIGNAL(clicked
()),
0,
0);
QObject::connect(btn,
SIGNAL(clicked
()),
this,
SLOT(hookedclicked
()) );
}
private slots:
void hookedclicked()
{
// do some processing
// invoke original slot - how? with QMetaObject::invokeMethod?
}
}
class objBtnHook
{
public:
objBtnHook (QAbstractButton* btn)
{
// how to store connected slot that is currently connected to the "clicked" signal?
QObject::disconnect (btn, SIGNAL(clicked()),0,0);
QObject::connect(btn, SIGNAL(clicked()), this, SLOT(hookedclicked()) );
}
private slots:
void hookedclicked()
{
// do some processing
// invoke original slot - how? with QMetaObject::invokeMethod?
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks