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. #17
    Join Date
    Aug 2006
    Location
    istanbul, turkey
    Posts
    42
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

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

    OK let me explain what cxl2253 is trying to do?

    Assume that you have a C library.
    In the library's documentation you have a callback function about the progress of some event. So when this callback is called then cxl2253 want to emit a signal for passing info to related object.
    Ok, let's make it clear.
    Assume that you want to wrap a class to convert C library to C++ object. As used library's docs says you need to use a callback func, but callbacks are not encouraged in C++ so what else to do?
    Then use a static class member. In this case static funcs cannot contain class wide variables.

    But off course there are tricks to make them available.


    But there is two things to take care of before using these tricks:
    1. If you're using the callbacks within QThread, don't do any GUI thread operations. Do with

    Qt Code:
    1. QApplication::postEvent()
    To copy to clipboard, switch view to plain text mode 

    whatever you do.
    2. If you use emit within the QThread emit is syncronious, this means you're directly reaching the GUI thread so this is undefined behaviour also.

    As a result you had better forget emit in static class functions if It's used in QThread.
    Last edited by hayati; 28th March 2007 at 18:53.

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.