Results 1 to 2 of 2

Thread: Help with interfacing C loop with QT

  1. #1

    Default Help with interfacing C loop with QT

    Dear all,

    I am really new at Qt, but I have a bit of experience with C (mostly) and with C++ (a bit).

    I have the folowing situation: a C application that periodically calls a processing function, let's say process() with some input data. Now, inside this process() function, I receive the input data (an RGB pixel buffer) and I want to display it in a QT GUI, through something like:

    QLabel myLabel;
    myLabel.setPixmap(QPixmap::fromImage(myImage));
    myLabel.show();

    (this is the simplest way to display an image that I found).

    Now, I know how to build a QImage object (the above myImage) from that input data that comes to process(). But how to display all that in a QT QUI *without* blocking the process() function with an app.exec()?

    The solution that I implemented is to launch a separate thread (with pthread_create()) in the init part of my application, and in that thread to create a QApplication and the GUI displaying the QLabel myLabel object. Then, that thread can run app.exec() without blocking my process() function.

    But, the big question is now: how to convince my QLabel to update itself with the new image generated from the data that I receive with each call of process()?

    Thank you.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Help with interfacing C loop with QT

    [wiki]Keeping the GUI Responsive[/wiki]
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 4
    Last Post: 6th August 2011, 01:40
  2. Main loop thread loop communication
    By mcsahin in forum Qt Programming
    Replies: 7
    Last Post: 25th January 2011, 16:31
  3. Interfacing with the Facebook API
    By wswartzendruber in forum Newbie
    Replies: 2
    Last Post: 20th July 2009, 22:18
  4. main loop
    By dusza in forum Qt Programming
    Replies: 10
    Last Post: 6th June 2009, 17:29
  5. while loop question..
    By b1 in forum Qt Programming
    Replies: 3
    Last Post: 25th May 2009, 10:48

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.