I am trying to implement the sleep function of QT Qthread, so I declared it in the header file as--
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
static void sleep(unsigned long secs){QThread::sleep(secs);}
protected:
void changeEvent(QEvent *e);
private:
Ui::MainWindow *ui;
private slots:
void on_pushButton_clicked();
};
and in my source code what I am doing is after connecting to a database, I want a label to change background color (sort of like a glowing effect), so I tried calling the sleep function from inside a while(true) loop.
while(db.open())
{
MainWindow::sleep(13);
qDebug()<<"Success ";
ui->glow_label->setStyleSheet("QLabel {background-color: rgb(0, 255, 0);}");
MainWindow::sleep(5);
ui->glow_label->setStyleSheet("QLabel {background-color: rgb(0, 85, 255);}");
}
But it shows error during build time-->
/usr/local/Trolltech/Qt-4.8.4/include/QtCore/qthread.h:115: error: ‘static void QThread::sleep(long unsigned int)’ is protected /home/aj/MY_QT_WORK/timer_test/mainwindow.h:22: error: within this context
Any ideas where I am doing wrong ???