[Interest] A suggestion about replacing signals, actions and slots
Oleg Yarigin
dralife at yandex.ru
Thu Dec 27 15:35:33 CET 2012
Hello,
I read http://byuu.org/articles/qt and got a question, why Qt uses slots and signals? That stuff can be safe replaced with function pointers. I am sure, it can give some advantages.
For instance, for now we need to use something like this to connect callbacks (actions):
connect( <a>, <a`s action>, <b>, <b`s slot> );
then we use moc, Q_OBJECT macro and special "slots:" class section.
I hope, this stuff can be better (with a way below we do not need to use moc, qmake and have an overhead in Qt library):
Action holder:
class QWidget
{
public:
void QObject::* slotFoo ( int, int, void* );
void QObject::* eventClose ( QCloseInfo* );
}
QWidget::WidgetNeedsToCallAMethod()
{
if( slotA ) slotFoo( 12, 15 );
}
Slot holder:
class OurClass : public QMainWindow
{
void createAction()
{
QAction a();
a.slotA = eventClose(); //Instead of connect() function
}
public:
void eventClose ( int a, int b ){ ... }
}
What do you think about it? If you are agree, I will create a new brunch in Qt repo for making these changes.
------
Oleg.
More information about the Interest
mailing list