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. Qtconcurrent, multithread, invoke
QtWS25 Last Chance

Qtconcurrent, multithread, invoke

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 340 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.
  • M Offline
    M Offline
    minjunkim
    wrote on last edited by
    #1

    hi, i want to show MyDialog by using concurrent

    MyDialog is created in mainClass.

    i try to call MyDialog in anotherClass by using concurrent

    but..

    below is my code and error

    <main.cpp>
    QtConcurrent::run(myDialogClass, &MyDialogClass::print, QString::fromLocal8Bit("show dlg"));

    <MyDialogClass.cpp>
    void MyDialogClass::print(QString msg)
    {
    this->setVisible(true); // error (cannot send events to objects owned by a different thread.)

    i think that it is mainThread, non-mainthread problem

    I solved a similar problem by using invoke method in c #.
    This is a feature that forces it to be executable in other classes.

    Can i do something similar in qt?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Yes it thread issue. You need to use in main thread only.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      M 1 Reply Last reply
      1
      • dheerendraD dheerendra

        Yes it thread issue. You need to use in main thread only.

        M Offline
        M Offline
        minjunkim
        wrote on last edited by
        #3

        @dheerendra

        thank you!

        i solved this problem by using Signal SLots mechanism in main thread

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          That is the right way.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0

          • Login

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