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. How to execute a Thread(QwtSamplingThread) for sometime and making the GUI(mainwindow) wait for 3 seconds?.
Forum Updated to NodeBB v4.3 + New Features

How to execute a Thread(QwtSamplingThread) for sometime and making the GUI(mainwindow) wait for 3 seconds?.

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 564 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.
  • T Offline
    T Offline
    thippu
    wrote on last edited by thippu
    #1

    Hi Guys,
    I have created class filethread which inherits the QwtSamplingThread for filereading it executes one function in run()
    filethread.cpp code:

    void Filethread::run()
    {
      scanfile()
    }
    

    main.cpp
    code:

    int main()
    {
    QApplication a(argc,argv);
    FileThread thread;
    thread.start();//this qwt thread I want it to complete the task for 3 seconds and then the compiler to star the mainwindow object which is GUI thread because this will get the data vector from the Filethread object.
    MainWindow w;//this should be started after the filethread object complition.
    w.resize(800,400);
    w.show();
    bool endapp=a.exec();
    thread.stop();
    return endapp;
    

    I want qwtthread to execute first and complete it the task for 3 seconds and after this mainwindow obj.show should execute, how to do this?
    how to do this, please help.

    1 Reply Last reply
    0
    • FlotisableF Offline
      FlotisableF Offline
      Flotisable
      wrote on last edited by
      #2

      I think you can emit a signal when the qwt thread complete it's task.
      And connect the signal to a slot of mainwindow.
      Then let the mainwindow to do the things.

      1 Reply Last reply
      3
      • T Offline
        T Offline
        thippu
        wrote on last edited by
        #3

        I would like to implement this and see. Thanks for the idea.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          The quick and silly method: QTimer::singleShot(3000, &w, &QMainWindow::show);

          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

          • Login

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