hi every one.
i write this cod.
how i can change progress bar value from my thread?
signal and slots?
how use signal and slots for this program??
main.cpp
#include "mainwindow.h"
#include <QApplication>
#include <QThread>
#include <QDebug>
#include <mainwindow.h>
int i ;
{
private:
void run()
{
for(i;i<=100;i++)
}
};
int main(int argc, char *argv[])
{
MainWindow w;
w.show();
//Thread();
qDebug()<<"From main thread: "<<QThread::currentThreadId();
Thread t;
QObject::connect(&t,
SIGNAL(finished
()),
&a,
SLOT(quit
()));
t.start();
//--------------------
//---------------------------------------
return a.exec();
}
#include "mainwindow.h"
#include <QApplication>
#include <QThread>
#include <QDebug>
#include <mainwindow.h>
int i ;
class Thread : public QThread
{
private:
void run()
{
for(i;i<=100;i++)
QThread::sleep(1);
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
//Thread();
qDebug()<<"From main thread: "<<QThread::currentThreadId();
Thread t;
QObject::connect(&t, SIGNAL(finished()), &a, SLOT(quit()));
t.start();
//--------------------
//---------------------------------------
return a.exec();
}
To copy to clipboard, switch view to plain text mode
mainwindow.cpp:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QApplication>
extern int i;
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_pressed()
{
// ui->progressBar->setValue(i);
//ui->progressBar->update();
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QApplication>
extern int i;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_pressed()
{
// ui->progressBar->setValue(i);
//ui->progressBar->update();
}
To copy to clipboard, switch view to plain text mode
Bookmarks