开发者

Call Slot of different class

I want to execute the slot of different class. When i execute this code its compiling without any error but not getting Output

pendrive1::pendrive1()
{
    UI_CDBurn Obj; 
connect( Obj.penDrive, SIGNAL(clicked()),&Obj , SLOT(caller()));
}

Here my slot is not working. Slot in UI_CDBurn is public. But when i called with a button in pendrive1 class its working fine

UI_CDBurn *Obj=new UI_CDBurn; 
connect( ui.pu开发者_StackOverflow社区shButton, SIGNAL(clicked()),Obj , SLOT( caller())); // Working File


First, What is pendrive? It must be a pointer to a QObject derived class with a signal named clicked.

I guess you have declared the clicked signal in the [pendrive] class but is the signal emitted? When the user click you need to emit the clicked signal with the following instruction:

emit clicked();

You can find how to use custom signals and slots here: http://doc.trolltech.com/4.5/signalsandslots.html.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜