2013年9月16日星期一

[Android] Signals and slots question puzzled , seeking guidance

Great God First, there are the Widget class inherits QWidget, then WidgetMain total inheritance Widget.
then WidgetMain created a button and define a slot in the constructor WidgetMain connect signals and slots .

this-> connect (m_startButton, SIGNAL (clicked ()), this, SLOT (startButton ()));

compile time. Has been
Object :: connect: No such slot Widget :: startButton () in .. / widgetmain.cpp: 37
Object :: connect: (receiver name: 'Widget')

Do WidgetMain constructor 's this pointer is a pointer to a base class object ? Instead of pointing to the class object ?
then how to do it
------ Solution ------------------------------- -------------
your slot function is defined in that class inside ? Inside this refers to the respect that you are connected categories, namely the parent class
If your tank functions directly in the words defined in the WidgetMain
direct connect (m_startBtn, SIGNAL (Ckicked ()), this, SLOT (startBtn ()));
------ eference -------- -------------------------------
connect the front do not use this right . QApplication :: right
------ eference ----------------------------------- ----
Well , it turns out that I did not write Q_OBJECT

没有评论:

发表评论