Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "MainWindow.h"
- MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
- {
- ui.setupUi(this);
- QObject::connect(this->ui.pushbutton, SIGNAL(clicked()), this, SLOT(process()));
- }
- void MainWindow::process()
- {
- ListCalc m_Calcul(ui.qprogressbar);
- auto thread = new QThread();
- m_Calcul->moveToThread(thread);
- m_Calcul.process(); // This is the action I would like to put in a thread !
- }
- #include "ListCalc.h"
- using namespace std;
- namespace Ui {
- class MainWindow;
- }
- class MainWindow : public QMainWindow
- {
- Q_OBJECT
- private:
- Ui::MainWindowClass ui;
- public:
- MainWindow(QWidget *parent = Q_NULLPTR);
- ListCalc m_Calcul;
- private slots:
- void process();
- };
- #include "ListCalc.h"
- ListCalc::ListCalc(QProgressBar* bar) :
- m_Bar(bar)
- {
- }
- ListCalc::~ListCalc()
- {
- }
- void ListCalc::process()
- {
- auto size = 30000;
- for (auto i = 0;i < size;++i)
- {
- m_Bar->setValue(i / size * 100);
- std::cout<<"1"<<std::endl;
- }
- }
- class ListCalc : public QObject
- {
- Q_OBJECT
- public:
- ListCalc(QProgressBar*);
- ~ListCalc();
- private:
- QProgressBar* m_Bar;
- public slots:
- void process();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement