Results 1 to 20 of 33

Thread: how to emit signal in a static function ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Join Date
    Dec 2006
    Posts
    36
    Thanked 1 Time in 1 Post

    Default Re: how to emit signal in a static function ?

    yes,you are all right. now I found a solution way. USED a static variable to record this address,then call non-static member function of the class.JUST LIKE THAT.
    //mythread.h
    1 static unsigned long classAddress;
    2 class myclass: public QThread
    3 {
    Q_Object
    4 private:
    5 static void myfuntion(); // callback function
    6 protected:
    7 void run();
    8 static void emitMsg( unsigned long user_value,char * filename)
    9 {
    10 myclass* pthis = (myclass*)user_value; // get this address
    11 pthis->emit storescpProgressInfo(filename) ;
    12 }
    13 signals:
    14 void storescpProgressInfo(char * filename);
    15 }

    //mythread.cpp
    16 void myclass::myfuntion(char * filename)
    17 {
    18 classAddress =(unsigned long)this ;
    19 emitMsg(classAddress,filename);
    20 }

    //main.cpp
    21 frmmainWindow::frmmainWindow()
    22 {
    23 myclass my;
    24 connect(&my,SIGNAL(storescpProgressInfo(char *)),this,SLOT(myslot(char *)));
    25 }

    the myclass can emit the signal,
    but frmmainwindow cannot receive the SIGNAL and not load the myslot function, what's wrong ? can you help ?

  2. The following user says thank you to cxl2253 for this useful post:


Similar Threads

  1. Replies: 16
    Last Post: 23rd May 2008, 10:12
  2. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52
  3. From extends QTreeWidgetItem emit signal?
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 19th May 2006, 14:54
  4. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52
  5. emit a signal
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 27th February 2006, 11:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.