ThreadDialog
::ThreadDialog(QWidget *parent
){
...
QPixmap pixmap
(width
(), height
()-100);
pixmap.fill(Qt::white);
threadA = new CircleThread(label, &pixmap, 50);
threadB = new CircleThread(label, &pixmap, 100);
connect(threadAButton, SIGNAL(clicked()),
this, SLOT(startOrStopThreadA()));
connect(threadBButton, SIGNAL(clicked()),
this, SLOT(startOrStopThreadB()));
connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
...
}
ThreadDialog::ThreadDialog(QWidget *parent)
: QWidget(parent)
{
...
label = new QLabel(this);
QPixmap pixmap(width(), height()-100);
pixmap.fill(Qt::white);
threadA = new CircleThread(label, &pixmap, 50);
threadB = new CircleThread(label, &pixmap, 100);
connect(threadAButton, SIGNAL(clicked()),
this, SLOT(startOrStopThreadA()));
connect(threadBButton, SIGNAL(clicked()),
this, SLOT(startOrStopThreadB()));
connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
...
}
To copy to clipboard, switch view to plain text mode
void ThreadDialog::startOrStopThreadA()
{
if (threadA->isRunning()) {
threadA->stop();
threadAButton->setText(tr("Start A"));
} else {
threadA->start();
threadAButton->setText(tr("Stop A"));
}
}
void ThreadDialog::startOrStopThreadA()
{
if (threadA->isRunning()) {
threadA->stop();
threadAButton->setText(tr("Start A"));
} else {
threadA->start();
threadAButton->setText(tr("Stop A"));
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks