Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QThread struct reponse example ?
Forum Updated to NodeBB v4.3 + New Features

QThread struct reponse example ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qthreadstruct
2 Posts 2 Posters 884 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RahibeMeryem
    wrote on last edited by kshegunov
    #1

    Hi ,

    I have worker Thread and defined a strcut:

    struct response{
            QImage _qimage;
            QString _t1;
            qint16 _int1;
        };
        response cevap;
    
        void _frameChangedStruct (const response &cevap);
    

    and in main:

    connect(worker, SIGNAL(_frameChangedStruct(response)), this , SLOT(displayFrame(response)));
    
    void MainWindow::displayFrame(QImage qimg){
    
    
           ui->FrameWindow->setPixmap(QPixmap::fromImage(cevap_._qimage));
    
    }
    

    It is not updating the widget. What is the correct way to pass a struct to the main thread ?

    thx

    [Fixed code tags ~kshegunov]

    kshegunovK 1 Reply Last reply
    0
    • R RahibeMeryem

      Hi ,

      I have worker Thread and defined a strcut:

      struct response{
              QImage _qimage;
              QString _t1;
              qint16 _int1;
          };
          response cevap;
      
          void _frameChangedStruct (const response &cevap);
      

      and in main:

      connect(worker, SIGNAL(_frameChangedStruct(response)), this , SLOT(displayFrame(response)));
      
      void MainWindow::displayFrame(QImage qimg){
      
      
             ui->FrameWindow->setPixmap(QPixmap::fromImage(cevap_._qimage));
      
      }
      

      It is not updating the widget. What is the correct way to pass a struct to the main thread ?

      thx

      [Fixed code tags ~kshegunov]

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      response is quite different from QImage, so you should start by matching your function prototypes. To that end you should use the Qt5 connect syntax, which is going to throw you a compile-time error for that code, as it justifiably should. I don't understand the rationale between that global variable - response cevap; though, you should explain what prompted you to use it like this.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      4

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved