Results 1 to 3 of 3

Thread: Integrating Pthread Library with QT

  1. #1
    Join Date
    Jan 2017
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Integrating Pthread Library with QT

    In my project is based on the Linux OS and I have two parts of code.

    One GUI implemented with QT and the other part is Libraries implemented using Standard C++(these libraries used across multiple systems to communicate, We can't replace with Qthreads) using pthread.

    To make Qt successfully call the library, I add "-lpthread" in Qt's .pro file.

    When I run Qt, problems come. Sometimes Qt is crashing in GUI update function.

    ProcessStatusDetails function is called pthred to update the status on to GUI


    int ProcessStatusDetails(StatusDetails* Status,std::string& StatusMsg)
    {
    int Erc;

    pthread_mutex_lock( &mutex1 );
    Erc = pMainWindow->UpdateGuiDetails(PisStatus,StatusMsg);
    pthread_mutex_unlock( &mutex1 );

    }

    Could some one help me how to signal the GUI update from Pthread function.?

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Integrating Pthread Library with QT

    GUI allowed to operate only in the main thread.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Integrating Pthread Library with QT

    Quote Originally Posted by bandarus View Post
    To make Qt successfully call the library, I add "-lpthread" in Qt's .pro file.
    Not sure why this would be necessary, Qt already links with libpthread.

    Quote Originally Posted by bandarus View Post
    Could some one help me how to signal the GUI update from Pthread function.?
    Via a signal connected to a slot of an object on the GUI thread or by calling a slot of such an object via QMetaObject::invokeMethod() with connection type Qt::QueuedConnection or by posting a custom event to an object on the GUI thread.

    Cheers,
    _

Similar Threads

  1. problem in using pthread in QT
    By rinku in forum Newbie
    Replies: 4
    Last Post: 27th September 2012, 13:07
  2. Qthread faster than pthread???
    By lsantos in forum Qt Programming
    Replies: 1
    Last Post: 16th April 2012, 21:58
  3. qt-4.5.3 linking issue (excessive pthread)
    By Ronayn in forum Qt Programming
    Replies: 1
    Last Post: 7th April 2011, 14:48
  4. -pthread havoc
    By Cruz in forum Qt Programming
    Replies: 8
    Last Post: 10th March 2010, 12:22
  5. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.