int main(int argc, char *argv[]) { BrowserApplication a(argc, argv); //MainWindow w; BrowserMainWindow w; QRect maxRect; { QDesktopWidget desktop; maxRect = desktop.availableGeometry(); maxRect.adjust(50,50,-50,-50); } w.setGeometry(maxRect); qDebug() << QApplication::applicationDirPath() << QApplication::applicationFilePath(); { QPixmap splashPixmap(QApplication::applicationDirPath() + "/comm/conf/pics/splash.png"); QSplashScreen splash(splashPixmap); splash.show(); enum { splashTime = 1500 }; QTimer timer; timer.start(splashTime); do { a.processEvents(); splash.showMessage(QString("Loading Process: %1%").arg(timer.remainingTime()*100.0/splashTime),Qt::AlignBottom); } while(timer.remainingTime() > 1); splash.finish(&w); } w.show(); a.processEvents(); return a.exec(); }
static int lua_sleep(lua_State *L) { int m = static_cast<int> (luaL_checknumber(L,1)); QTimer timer; timer.start(m); while(timer.remainingTime() > 0) qApp->processEvents(); LuaManager::LuaControl.forceMapUpdate(); return 0; }
void tst_QTimer::remainingTime() { TimerHelper helper; QTimer timer; connect(&timer, SIGNAL(timeout()), &helper, SLOT(timeout())); timer.start(200); QCOMPARE(helper.count, 0); QTest::qWait(50); QCOMPARE(helper.count, 0); int remainingTime = timer.remainingTime(); QVERIFY2(qAbs(remainingTime - 150) < 50, qPrintable(QString::number(remainingTime))); }
void RICTLMB2B30Widget::btWriteClicked() { ui->labelRectangleStatus->close(); if((!ui->rbDecimal->isChecked() && !ui->rbHexadecimal->isChecked())){ SystemMessagesWidget::instance()->writeMessage(tr("Please, select the identification type."), SystemMessagesWidget::KWarning, SystemMessagesWidget::KDialogAndTextbox); return; } if(ui->leIdentification->text().isEmpty()){ SystemMessagesWidget::instance()->writeMessage(tr("The identification must have at least 1 characters."), SystemMessagesWidget::KWarning, SystemMessagesWidget::KOnlyDialog); return; } QString message(tr("Wait... Trying to write.")); SystemMessagesWidget::instance()->writeMessage(message, SystemMessagesWidget::KInfo); ui->labelRectangleStatus->setText(message); ui->labelRectangleStatus->setStyleSheet("QLabel { background-color : yellow;}"); ui->labelRectangleStatus->show(); //Process the events to repaint the widget with the new labelRectangleStatus. QCoreApplication::processEvents(); ui->btWrite->setEnabled(false); // Mark the processing to check for a answers on reading. m_waitingForAnswer = true; if(m_connectionType == Settings::KNetwork){ int interval = 500; QTimer timer; timer.setSingleShot(true); NetworkCommunication::instance()->sendFullRead(true); timer.start(interval); while(timer.remainingTime() > 0) ; sendCommand("L"); timer.start(interval); while(timer.remainingTime() > 0) ; sendCommand("K0"); timer.start(interval); while(timer.remainingTime() > 0) ; sendCommand("P" + m_identification); }else{ /* Send the "L" command to the reader. This ensure that the reader operates in Line Mode. * It is needed to keep the reader responding for reads, to check the command responses * and the identification codes from transponder, automatically. */ sendCommand("L"); /* Send the "K0" command to the reader. This ensure that the reader understant it is working * with a 64-bits transponder, a K0. If the reader is not set with K0, it will not understand * the commands and will not answer, correctly. */ sendCommand("K0"); /* Send the "P" + identification code to the reader. This is the way to define a new code * to the trasponder. */ sendCommand("P" + m_identification); } // Start the timeout to wait for a response. If the timer ends, define as failed. m_timeout.start(); }