Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. Qt Contribution
  4. QPixmap- It is not safe to use QPixmap outside the gui Thread

QPixmap- It is not safe to use QPixmap outside the gui Thread

Scheduled Pinned Locked Moved Qt Contribution
4 Posts 3 Posters 4.4k Views
  • 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.
  • J Offline
    J Offline
    janaki
    wrote on 6 Aug 2013, 08:44 last edited by
    #1

    in main function my dialog is displayed
    and i have created a new pthread as follows

    pthread_t t1;
    pthread_create(&t1,NULL,&message,NULL);

    void * message(void *)
    {
    // data for receiving the buffer on udp
    //after receiving
    dialog d; // my gui
    d.display(buffer); // sending the received buffer to the gui function for displaying the values on the labels

    }

    when i run this code am getting the following error

    QPixmap- It is not safe to use QPixmap outside the gui Thread

    i have not used QPixmap then why this error
    am able to print the received data at the console but not able to set the text on the gui labels

    can any one suggest why

    }

    `

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Aug 2013, 08:55 last edited by
      #2

      Hi,

      You are using GUI elements outside the GUI thread and that's not allowed. You'll have to send your buffer to your main thread and from there show your dialog.

      Also, please enclose your code in coding tags (first icon to the right) so it's more readable :)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        janaki
        wrote on 6 Aug 2013, 10:14 last edited by
        #3

        my main thread code is as follows
        @
        main.cpp
        @

        int main()
        {

        QApplication a;
        Ground gs; // dialog name
        gs.show();
        return a.exec():
        }
        now my question how should i send it to main thread

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JKSH
          Moderators
          wrote on 6 Aug 2013, 11:17 last edited by
          #4

          Signals and slots can safely transfer data across threads

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0

          1/4

          6 Aug 2013, 08:44

          • Login

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