void Timelapse::setInterval(const QTime &time){ intervalTime->setHMS(time.hour(),time.minute(),time.second(),time.msec()); realinterval = interval = time.second()*1000+time.msec(); LOG_TIMELAPSE_DEBUG << "Timelapse setInterval: " << time.second() << time.msec() << interval; timer->setInterval(timerresolution); }
long GetElapsedMSecs(const QTime &startTime, const QTime &endTime) { int eHours = endTime.hour() - startTime.hour(); int eMinutes = endTime.minute() - startTime.minute(); int eSecs = endTime.second() - startTime.second(); int eMSecs = endTime.msec() - startTime.msec(); return eHours*60*60*1000 + eMinutes*60*1000 + eSecs*1000 + eMSecs; }
void TTCurrentFrameInfo::setFrameTime( QTime time_1, QTime time_2 ) { QString str_time; str_time.sprintf("%s,%d / %s,%d",time_1.toString().ascii(), time_1.msec(), time_2.toString().ascii(), time_2.msec() ); leFrameTime->setText( str_time ); }
QTime operator+(QTime l,QTime r) { int h=l.hour()+r.hour(),m=l.minute()+r.minute(),s=l.second()+r.second(),ms=l.msec()+r.msec(); if (ms>=1000) {ms=ms-1000;s++;} if (s>=60) {s-=60;m++;} if (m>=60) {m-=60;h++;} if (h>=24) {h-=24;} QTime re(h,m,s,ms); return re; }
QTime operator-(QTime l,QTime r) { int h=l.hour()-r.hour(),m=l.minute()-r.minute(),s=l.second()-r.second(),ms=l.msec()-r.msec(); if (ms<0) {ms=ms+1000;s--;} if (s<0) {s+=60;m--;} if (m<0) {m+=60;h--;} if (h<0) {h+=24;} QTime re(h,m,s,ms); return re; }
QString Soprano::DateTime::toString( const QTime& t ) { QString frac; if( t.msec() > 0 ) { frac.sprintf( ".%03d", t.msec() ); // remove trailing zeros while( frac.endsWith( '0' ) ) frac.truncate( frac.length() -1 ); } return t.toString( "HH:mm:ss" ) + frac; }
//Обновление консоли оповещени в GUI о начале и конце копиляции, её времени void Compiler::updateLog(QTime &startTime) { QTime endTime = QTime::currentTime(); if(out) { out->clear(); QString secnd = QString::number(abs(endTime.second() - startTime.second())); QString min = QString::number(abs(endTime.minute() - startTime.minute())); QString msecnd = QString::number(abs(endTime.msec() - startTime.msec())); QString outPutMsg = "Компиляция прошла успешно время: " + formatTime(min, 2) + ":" + formatTime(secnd, 2) + ':' + formatTime(msecnd, 3) ; mBar->setValue(mBar->maximum()); out->append(outPutMsg); } }
static PyObject *meth_QDateTime_toPyDateTime(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { QDateTime *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QDateTime, &sipCpp)) { PyObject * sipRes = 0; #line 484 "/home/tsheasha/GUC/Bachelors/android-python27/python-build/PyQt-x11-gpl-4.8/sip/QtCore/qdatetime.sip" if (!PyDateTimeAPI) PyDateTime_IMPORT; // Convert to a Python datetime object. QDate qd = sipCpp->date(); QTime qt = sipCpp->time(); sipRes = PyDateTime_FromDateAndTime(qd.year(), qd.month(), qd.day(), qt.hour(), qt.minute(), qt.second(), qt.msec() * 1000); #line 84 "sipQtCoreQDateTime.cpp" return sipRes; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QDateTime, sipName_toPyDateTime, NULL); return NULL; }
QList<int> MainScreen::randomizeBuyers() { QList<int> order; for(int i = 0; i < m_participants.size(); ++i) { order.append(i); } unsigned int size = m_participants.size(); unsigned int i = 0; // seed the random number generator with the current time QTime time = QTime::currentTime(); qsrand((uint)time.msec()); // Use Fisher-Yates to randomly swap indexes while(i < size) { int index = qrand(); index = index % size; int temp = order[index]; order[index] = order[i]; order[i] = temp; ++i; } return order; }
gamewidget::gamewidget(QWidget *parent) : QDialog(parent) { //background this->setAutoFillBackground(true); this->resize(391,220); this->setWindowTitle("snack"); QPalette palette; palette.setBrush(QPalette::Background,QBrush(QPixmap(":/new/prefix1/img/green.jpg"))); this->setPalette(palette); //button left_button = new QPushButton("Left",this); left_button->setGeometry(QRect(260,70,40,30)); right_button = new QPushButton("Right",this); right_button->setGeometry(QRect(340,70,40,30)); up_button = new QPushButton("Up",this); up_button->setGeometry(QRect(300,40,40,30)); down_button = new QPushButton("Down",this); down_button->setGeometry(QRect(300,70,40,30)); start_button = new QPushButton("Start",this); start_button->setGeometry(270,120,50,30); return_button = new QPushButton("Return",this); return_button->setGeometry(330,120,50,30); //signal and slot connect(left_button,SIGNAL(clicked()),this,SLOT(left_click())); connect(right_button,SIGNAL(clicked()),this,SLOT(right_click())); connect(up_button,SIGNAL(clicked()),this,SLOT(up_click())); connect(down_button,SIGNAL(clicked()),this,SLOT(down_click())); connect(start_button,SIGNAL(clicked()),this,SLOT(start_click())); connect(return_button,SIGNAL(clicked()),this,SLOT(return_click())); //key singnal connect(this,SIGNAL(UpSignal()),this,SLOT(up_click())); connect(this,SIGNAL(DownSignal()),this,SLOT(down_click())); connect(this,SIGNAL(LeftSignal()),left_button,SLOT(click())); connect(this,SIGNAL(RightSignal()),right_button,SLOT(click())); //auto update timer = new QTimer(this); connect(timer,SIGNAL(timeout()),this,SLOT(timeoutslot())); //rand seed QTime t; t= QTime::currentTime(); qsrand(t.msec()+t.second()*1000); //head snake[0][0] = qrand()%ROW; snake[0][1] = qrand()%COL; //data init foodcount = 0; suicide = false; thesame = false; speed = 300; sound_eat = new QSound(":/sounds/eating.wav",this); sound_die = new QSound(":/sounds/gameover.wav",this); foodx = qrand()%ROW; foody = qrand()%COL; while (foodx==snake[0][0]&&foody==snake[0][1]) { foodx = qrand()%ROW; foody = qrand()%COL; } directioin = qrand()%4; }
void MainWindow::updateTimer() { int milisegundos, segundos, minutos; QTime timeAct = QTime::currentTime(); int minInicial = timeInicial.minute(); int minActual = timeAct.minute(); int segInicial = timeInicial.second(); int segActual = timeAct.second(); int msegInicial = timeInicial.msec(); int msegActual = timeAct.msec(); if (msegActual < msegInicial){ msegActual = 1000 + msegActual; segActual = segActual -1; } if (segActual < segInicial){ segActual = 60 + segActual; minActual = minActual -1; } minutos = minActual - minInicial; segundos = segActual - segInicial; milisegundos = (msegActual - msegInicial); QTime *time = new QTime(0,minutos,segundos,milisegundos); textTiempo = time->toString("mm:ss.zzz"); valorTiempo = milisegundos + segundos*1000 + minutos *60000; ui->lcdNumber->display(textTiempo); }
void ObjectSoup::run() { QTime time = QTime::currentTime(); qsrand((uint)time.msec()); // fill the world with objects KinematicModel::CompositeObject* obj[num]; for ( int i =0; i<num; ++i ) { // make a new object if (verbose) printf( "Composite Object: %d\n", i ); obj[i] = makeARandomObjectLikeAMothaFucka(); } /**/ int j; time.start(); while ( keepRunning ) { j = qrand() % (num); if (verbose) printf( "replacing object: %d\n", j ); obj[j]->kill(); obj[j] = makeARandomObjectLikeAMothaFucka(); msleep(20); } //printf("ObjectSoup::run() returned\n"); }
void Sudoku::ocultarCasillas(int nivel, Tablero *t){ int cont,tmp; QTime time = QTime::currentTime(); qsrand((uint)time.msec()); if(nivel==1) tmp=3; if(nivel==2) tmp=5; if(nivel==3) tmp=6; cont=tmp; for(int bloque=1;bloque<=9;bloque++){ while(cont>0){ for(int i=0;i<9;i++){ for(int j=0;j<9;j++){ if(cont>0){ if(t->casillas[0]->buscarRegion(i+1,j+1)==bloque){ if(t->randInt(0,1)==1){ matriz[i][j]=0; cont--; } } } } } } cont=tmp; } }
Operator::Operator(QObject *parent, Runner *runner, int id) : QThread(parent), runner(runner), id(id), tools(0), m1(0), m2(0), product(0), take_tool_attemp(0) { QTime time = QTime::currentTime(); srand((uint)time.msec() + id); }
WaveChart::WaveChart(QChart* chart, QWidget* parent) : QChartView(chart, parent), m_series(new QLineSeries()), m_wave(0), m_step(2 * PI / numPoints) { QPen blue(Qt::blue); blue.setWidth(3); m_series->setPen(blue); QTime now = QTime::currentTime(); qsrand((uint) now.msec()); int fluctuate = 100; for (qreal x = 0; x <= 2 * PI; x += m_step) { m_series->append(x, fabs(sin(x) * fluctuate)); } chart->addSeries(m_series); QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(update())); m_timer.setInterval(5000); m_timer.start(); }
/* * Generate a new SQRL identity. * Need to add **LOTS** of entropy here. */ bool SqrlIdentity::createIdentity() { qDebug() << "LOTS of entropy goes here"; qDebug() << "Security warning: don't use this key for anything but testing!"; QTime time = QTime::currentTime(); qsrand((uint) time.msec()); QByteArray seed = this->getRandomQByteArray(); qDebug() << "The generated seed is:" << seed; this->key = seed; QString folderName = QDir::homePath() + "/.sqrl"; if (!QDir(folderName).exists()) QDir().mkdir(folderName); QString fileName = "ident.txt"; QFile file(folderName + "/" + fileName); if (file.open(QIODevice::WriteOnly)) { QTextStream out(&file); for (unsigned int i = 0; i < SodiumWrap::SEED_LEN; ++i) { out << (char)this->key[i]; } file.close(); } else { qDebug() << "Error: couldn't open file for writing."; } return true; }
/** * @brief ChordTableWidget::setCaseAndFollowersBeginning * @param t nouveau temps de début de la première case à changer * * Appelé lorsque l'on change le temps de début d'une case et * que l'on veut changer le temps de toutes les cases qui suivent. */ void ChordTableWidget::setCaseAndFollowersBeginning(QTime t) { int minRow = this->row(m_currentItem); int minCol = this->column(m_currentItem); QTime old_t; QTime b_t = m_currentItem->getBeginning(); // on ajoutera à chaque case la différence entre l'ancien et le nouveau temps QTime add_t(qAbs(t.hour() - b_t.hour()), qAbs(t.minute() - b_t.minute()), qAbs(t.second() - b_t.second()), qAbs(t.msec() - b_t.msec())); for(int i = minRow; i < this->rowCount(); i++) { for(int j = 0; j < this->columnCount() - 1; j++) { if(i != minRow || j >= minCol) { old_t = ((CaseItem*) this->item(i, j))->getBeginning(); ((CaseItem*) this->item(i, j))->setBeginning(old_t.addMSecs(TimeToMsec(add_t))); } } } }
void Tohkbd::screenShot() { QDate ssDate = QDate::currentDate(); QTime ssTime = QTime::currentTime(); ssFilename = QString("%8/ss%1%2%3-%4%5%6-%7.png") .arg((int) ssDate.day(), 2, 10, QLatin1Char('0')) .arg((int) ssDate.month(), 2, 10, QLatin1Char('0')) .arg((int) ssDate.year(), 2, 10, QLatin1Char('0')) .arg((int) ssTime.hour(), 2, 10, QLatin1Char('0')) .arg((int) ssTime.minute(), 2, 10, QLatin1Char('0')) .arg((int) ssTime.second(), 2, 10, QLatin1Char('0')) .arg((int) ssTime.msec(), 3, 10, QLatin1Char('0')) .arg("/home/nemo/Pictures"); QDBusMessage m = QDBusMessage::createMethodCall("org.nemomobile.lipstick", "/org/nemomobile/lipstick/screenshot", "", "saveScreenshot" ); QList<QVariant> args; args.append(ssFilename); m.setArguments(args); if (QDBusConnection::sessionBus().send(m)) printf("Screenshot success to %s\n", qPrintable(ssFilename)); else printf("Screenshot failed\n"); notificationSend("Screenshot saved", ssFilename); }
void UI_JumpMenuDialog::absolutetime_changed(const QTime &time_2) { long long milliseconds; if(!mainwindow->files_open) return; QObject::disconnect(daybox1, SIGNAL(valueChanged(int)), this, SLOT(offsetday_changed(int))); QObject::disconnect(timeEdit1, SIGNAL(timeChanged(const QTime &)), this, SLOT(offsettime_changed(const QTime &))); milliseconds = (long long)(time_2.hour()) * 3600000LL; milliseconds += (long long)(time_2.minute()) * 60000LL; milliseconds += (long long)(time_2.second()) * 1000LL; milliseconds += (long long)(time_2.msec()); milliseconds += ((long long)daybox2->value() * 86400000LL); if(milliseconds<0) milliseconds = 0; milliseconds -= starttime; time1.setHMS((int)((milliseconds / 3600000LL) % 24LL), (int)((milliseconds % 3600000LL) / 60000LL), (int)((milliseconds % 60000LL) / 1000LL), (int)(milliseconds % 1000LL)); timeEdit1->setTime(time1); daybox1->setValue((int)(milliseconds / 86400000LL)); QObject::connect(daybox1, SIGNAL(valueChanged(int)), this, SLOT(offsetday_changed(int))); QObject::connect(timeEdit1, SIGNAL(timeChanged(const QTime &)), this, SLOT(offsettime_changed(const QTime &))); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); tcpClient = new QTcpSocket(this); ui->pushSent->setEnabled(false); this->ui->timeBut->setEnabled(false); tcpClient->abort(); connect(tcpClient,&QTcpSocket::readyRead, [&](){this->ui->textEdit->append(tr("%1 Server Say:%2").arg(QTime::currentTime().toString("hh:mm:ss.zzz")).arg(QString(this->tcpClient->readAll())));}); connect(tcpClient,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(ReadError(QAbstractSocket::SocketError))); connect(&tm,&QTimer::timeout,[&](){ int i = qrand() % 6; this->ui->textEdit->append(tr("%1 Timer Sent: %2").arg(QTime::currentTime().toString("hh:mm:ss.zzz")).arg(list.at(i))); tcpClient->write(list.at(i).toUtf8()); }); connect(tcpClient,&QTcpSocket::disconnected,[](){qDebug()<< "123333" ;}); list << "我是谁?" << "渡世白玉" << "hello" << "哈哈哈哈哈" << "你是坏蛋!" << "测试一下下了" << "不知道写什么" ; QTime time; time= QTime::currentTime(); qsrand(time.msec()+time.second()*1000); this->ui->txtIp->setText("127.0.0.1"); this->ui->txtPort->setText("6666"); }
/** \fn mythCurrentDateTime() * \brief Returns the current QDateTime object, stripped of its msec component */ QDateTime mythCurrentDateTime() { QDateTime rettime = QDateTime::currentDateTime(); QTime orig = rettime.time(); rettime.setTime(orig.addMSecs(-orig.msec())); return rettime; }
void CmaClient::connectWireless() { vita_device_t *vita; wireless_host_info_t host = {NULL, NULL, NULL, QCMA_REQUEST_PORT}; typedef CmaClient CC; QTime now = QTime::currentTime(); qsrand(now.msec()); qDebug("Starting wireless_thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId()); setActive(true); do { if((vita = VitaMTP_Get_First_Wireless_Vita(&host, 0, CC::cancelCallback, CC::deviceRegistered, CC::generatePin, CC::registrationComplete)) != NULL) { processNewConnection(vita); } else { Sleeper::msleep(2000); mutex.lock(); if(in_progress) { sema.acquire(); } mutex.unlock();; } } while(isActive()); qDebug("Finishing wireless_thread"); emit finished(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QTime time = QTime::currentTime(); qsrand((uint)time.msec()); QDir dir; readFile(dir.path() + "/vocabulario.txt"); ui->openLineEdit->setText(dir.path() + "/vocabulario.txt"); ui->spanishRB->setChecked(true); ui->correctLabel->setText("0"); ui->correctLabel->setStyleSheet("QLabel {color : red; }"); connect(ui->refreshButton, SIGNAL(clicked()), this, SLOT(refresh_clicked())); connect(ui->changeButton, SIGNAL(clicked()), this, SLOT(change_clicked())); connect(ui->spanish_lineEdit, SIGNAL(returnPressed()), this, SLOT(refresh_clicked())); connect(ui->slovak_lineEdit, SIGNAL(returnPressed()), this, SLOT(refresh_clicked())); connect(ui->openButton, SIGNAL(clicked()), this, SLOT(open_clicked())); refresh_clicked(); }
AI::Direction AI::randomDirection() const { QTime time = QTime::currentTime(); qsrand((uint)time.msec()); return (AI::Direction) (qrand() % 4); }
// Convert from QDateTime to chartTime static double QDateTimeToChartTime(QDateTime q) { QDate d = q.date(); QTime t = q.time(); return Chart::chartTime(d.year(), d.month(), d.day(), t.hour(), t.minute(), t.second()) + t.msec() / 1000.0; }
NewGraphDialog::NewGraphDialog(DBCHandler *handler, QWidget *parent) : QDialog(parent), ui(new Ui::NewGraphDialog) { ui->setupUi(this); dbcHandler = handler; connect(ui->colorSwatch, SIGNAL(clicked(bool)), this, SLOT(colorSwatchClick())); connect(ui->btnAddGraph, SIGNAL(clicked(bool)), this, SLOT(addButtonClicked())); // Seed the random generator with current time QTime time = QTime::currentTime(); qsrand((uint)time.msec()); QPalette p = ui->colorSwatch->palette(); //using 160 instead of 255 so that colors are always at least a little dark p.setColor(QPalette::Button, QColor(qrand() % 160,qrand() % 160,qrand() % 160)); ui->colorSwatch->setPalette(p); connect(ui->cbMessages, SIGNAL(currentIndexChanged(int)), this, SLOT(loadSignals(int))); connect(ui->cbSignals, SIGNAL(currentIndexChanged(int)), this, SLOT(fillFormFromSignal(int))); loadMessages(); }
void QtCamMetaData::setDateTime(const QDateTime& dateTime) { QDate d = dateTime.date(); QTime t = dateTime.time(); int day = d.day(); int month = d.month(); int year = d.year(); int hour = t.hour(); int minute = t.minute(); // GstDateTime seconds expects microseconds to be there too :| gdouble seconds = t.second(); seconds += t.msec()/(1000.0); // Current UTC time. Created through string so that the link between // current and utc is lost and secsTo returns non-zero values. QDateTime utcTime = QDateTime::fromString(dateTime.toUTC().toString()); gfloat tzoffset = (utcTime.secsTo(dateTime)/3600.0); GstDateTime *dt = gst_date_time_new(tzoffset, year, month, day, hour, minute, seconds); d_ptr->addTag(GST_TAG_DATE_TIME, dt); gst_date_time_unref(dt); }
static DATE QDateTimeToDATE(const QDateTime &dt) { if (!dt.isValid() || dt.isNull()) return 949998; SYSTEMTIME stime; memset(&stime, 0, sizeof(stime)); QDate date = dt.date(); QTime time = dt.time(); if (date.isValid() && !date.isNull()) { stime.wDay = date.day(); stime.wMonth = date.month(); stime.wYear = date.year(); } if (time.isValid() && !time.isNull()) { stime.wMilliseconds = time.msec(); stime.wSecond = time.second(); stime.wMinute = time.minute(); stime.wHour = time.hour(); } double vtime; SystemTimeToVariantTime(&stime, &vtime); return vtime; }
// Elapsed time. This implementation assumes that the maximum elapsed time is // less than 48 hours. ElapsedTime::ElapsedTime() { QTime now = QTime::currentTime(); bigBit = now.hour() * 60 * 60 + now.minute() * 60 + now.second(); littleBit = now.msec(); }
Board::Board(QWidget *parent, IGame * _activeGame) : QWidget(parent) { activeGame = _activeGame; QTime time = QTime::currentTime(); srand((uint)time.msec()); qsrand((uint)time.msec()); this->resize(500, 500); setMouseTracking(true); }