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 with a GUI
Forum Updated to NodeBB v4.3 + New Features

QThread with a GUI

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 590 Views 2 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.
  • E Offline
    E Offline
    EL-jos
    wrote on last edited by EL-jos
    #1

    Good morning, everyone,
    still in my learning with QThread, I have a problem, like how to adapt a QThread with a graphical interface;
    here is my problem: I have a server and I want to use the thread in my server class, knowing that it has several functions in its breast, example of the code:

    
    
    class server
    {
        public:
    
        serveur(QObject *parent);
    
        void function1();
        void function2();
        void function3();
        void function4();
    
        signals:
        //
    
        public slot:
        //
    
        private:
    
        int number
        QString string;
    }
    

    now I'm asking myself a question, do I have to make the Server class inherit QThread to execute several functions simultaneously?
    and if so, how to execute function1(), function2() and function5() at the same time?

    Thank you in advance for your help

    1 Reply Last reply
    0
    • CKurduC Offline
      CKurduC Offline
      CKurdu
      wrote on last edited by CKurdu
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by SGaist
        #3

        Hi,

        Before starting to play with threads, take a look at the QtConcurrent module. It might do what you need without having to dive into the subtleties of threading.

        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
        2
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          One option as suggested by @SGaist

          1. QtConcurrent module. Still if you want to
          2. Inherit your object from QObject. Create thread object, Move your object to QThread.
          3. Last option is you have inherit from QThread and implement run method.
            If you want to run all the three methods at same time, multiple thread objects are required.

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

          1 Reply Last reply
          1

          • Login

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