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. #19
    Join Date
    Dec 2006
    Posts
    36
    Thanked 1 Time in 1 Post

    Default

    thanks all . I found that it's impossible to emit the signal in static function .Now I play the trick. I not emit the signal to inform the object which is out of the thread, I directly implement the code that shouble be in SLOT range. Because it is non-static member function of class ,i have to load it into static function.I used the trick mentioned before, used "this" address .
    thanks all again.

    Other more, if want to use QApplication.poseEvent(), what should i do ? in BCB,I can just write like that .
    Qt Code:
    1. /////////////cfrmmain.h///////
    2. enum { NM_STORESCP_CALLBACK = WM_USER + 100 };
    3. void __stdcall MyStoreScpCallback(T_StoreProgress* progress, LPCSTR filename);
    4. class TfrmMain : public TForm
    5. {
    6. BEGIN_MESSAGE_MAP
    7. VCL_MESSAGE_HANDLER(NM_STORESCP_CALLBACK, TMessage, OnStoreSCPCallback);
    8. END_MESSAGE_MAP(TForm);
    9. }
    10. //////////////cfrmmain.cpp////////
    11. void __stdcall MyStoreScpCallback(T_StoreProgress* progress, LPCSTR filename)
    12. {
    13. ///emit the message user defined :in QT ,how to postEvent and get the receive ????
    14. SendMessage(Application->MainForm->Handle, NM_STORESCP_CALLBACK,
    15. (WPARAM)progress, (LPARAM)filename);
    16. }
    17. void __fastcall TfrmMain::OnStoreSCPCallback(TMessage &Message)
    18. {
    19. ///response to the message ,do something accoring to WPARAM LPARAM
    20. }
    21. void __fastcall TfrmMain::FormShow(TObject *Sender)
    22. {
    23. //now callback here
    24. storescp_execute(m_iServerPort, MyStoreScpCallback);
    25. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 29th March 2007 at 06:20. Reason: Posts merged

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.