Results 1 to 20 of 22

Thread: Problem emitting signal from a static function

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: Problem emitting signal from a static function

    how he solved it isn't really applicable in my case
    and
    and the overhead of creating an object, setting up the signals and connecting the to the GUI threads slots is an excessive amount of overhead I feel
    Have nothing in common.
    Here is the code:
    Qt Code:
    1. static void emitMsg( unsigned long user_value,char * filename)
    2. {
    3. myclass* pthis = (myclass*)user_value; // get this address
    4. pthis->emit storescpProgressInfo(filename) ;
    5. }
    To copy to clipboard, switch view to plain text mode 

    No allocation, no setting up connections, no nothing, just emiting a signal.
    You set the connection there where the emitting and receiving object are visible, and you only need to do it once.
    But then again, I don't really know what it is you are trying to do (appart from emiting a signal in a callback.).
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  2. #2
    Join Date
    Aug 2006
    Posts
    163
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    12
    Thanked 5 Times in 4 Posts

    Default Re: Problem emitting signal from a static function

    Quote Originally Posted by high_flyer View Post
    and


    Have nothing in common.
    Here is the code:
    Qt Code:
    1. static void emitMsg( unsigned long user_value,char * filename)
    2. {
    3. myclass* pthis = (myclass*)user_value; // get this address
    4. pthis->emit storescpProgressInfo(filename) ;
    5. }
    To copy to clipboard, switch view to plain text mode 
    No allocation, no setting up connections, no nothing, just emiting a signal.
    You set the connection there where the emitting and receiving object are visible, and you only need to do it once.
    But then again, I don't really know what it is you are trying to do (appart from emiting a signal in a callback.).
    You are right, the slots would only be set up when the decoder si initially created. However, it seems a bit messy. If the way I'm trying to do it now doesn't work I'll give it a shot.

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: Problem emitting signal from a static function

    But what is the way you are trying?
    I am not clear on how you want to integrate QEvent in the external library?
    Is it an open source lib?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Aug 2006
    Posts
    163
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    12
    Thanked 5 Times in 4 Posts

    Default Re: Problem emitting signal from a static function

    Was my explanation that bad?

    I am decoding files in a QThread. I am doing that using an open-source library, called uulib. It is THE library for decoding Usenet multipart files, which is what my program does. Well, it downloads them, but you get the picture. Now, rather than go through all the hassle of reinventing the wheel, I link against uulib and let it decode the files for me that my program has downloaded. However, uulib is a C library, and uses function callbacks to do certain things, one of which is to display it's progress during decoding. I would like to set up a function callback, and then do some calculations in it to determine the progress so far, and then to fire off a signal to the GUI thread so that it can update a progress bar with the progress of the decoder. Hence my whole problem

Similar Threads

  1. how to emit signal in a static function ?
    By cxl2253 in forum Qt Programming
    Replies: 32
    Last Post: 7th July 2016, 21:36
  2. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  3. Replies: 3
    Last Post: 15th April 2007, 19:16
  4. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52
  5. 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

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.