本文整理汇总了C++中QTime::hour方法的典型用法代码示例。如果您正苦于以下问题:C++ QTime::hour方法的具体用法?C++ QTime::hour怎么用?C++ QTime::hour使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTime
的用法示例。
在下文中一共展示了QTime::hour方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toDouble
/*!
Translate from QDateTime to double
\param dateTime Datetime value
\return Number of milliseconds since 1970-01-01T00:00:00 UTC has passed.
\sa toDateTime(), QDateTime::toMSecsSinceEpoch()
\warning For values very far below or above 1970-01-01 UTC rounding errors
will happen due to the limited significance of a double.
*/
double QwtDate::toDouble( const QDateTime &dateTime )
{
const int msecsPerDay = 86400000;
const QDateTime dt = qwtToTimeSpec( dateTime, Qt::UTC );
const double days = dt.date().toJulianDay() - QwtDate::JulianDayForEpoch;
const QTime time = dt.time();
const double secs = 3600.0 * time.hour() +
60.0 * time.minute() + time.second();
return days * msecsPerDay + time.msec() + 1000.0 * secs;
}
示例2: simplifiedDateToRect
QRect NextAvailabiliyManager::simplifiedDateToRect(const int weekDay, const QTime &start, const QTime &end)
{
// TOP : day of week
// 1px = 1minute
// linear Monday to Sunday
// 1 day = 1440 minutes
// X = month + day
// WIDTH = year
// HEIGHT = durationInMinutes
int day = (weekDay-1) * 1440;
int top = start.hour() * 60 + start.minute() + day;
int durationInMinutes = start.secsTo(end) / 60;
return QRect(0, top, 11, durationInMinutes);
}
示例3: correctFPTime
QTime SessionDefaults::correctFPTime(const QTime &time) const
{
int hour = time.hour();
int min = time.minute();
int sec = time.second();
int t = getFPLength() * 60 - hour * 3600 - min * 60 - sec;
hour = t/3600;
min = (t%3600)/60;
sec = (t%3600)%60;
QTime newTime(hour, min, sec);
return newTime;
}
示例4: on_buttonBox_accepted
void FileImportDialog::on_buttonBox_accepted() {
QFile f(fileLineEdit->text());
f.open(QFile::ReadOnly);
QString content = f.readAll();
QStringList trames = content.split("@");
int i=0;
QTime base = QTime::currentTime();
foreach(QString trame, trames) {
Data* d = m_parent->getSensorMgr()->addData(trame);
if(d != NULL)
d->time = QTime(base.hour(),base.minute(),base.second()+i);
i++;
}
示例5: testConsultResultXml
void EdrcPlugin::testConsultResultXml()
{
Utils::Randomizer r;
r.setPathToFiles(settings()->path(Core::ISettings::BundleResourcesPath) + "/textfiles/");
// Test Unique CR XML
ConsultResult r2;
r2.setConsultResult(1);
r2.setChronicDiseaseState(ConsultResult::ChronicDisease);
r2.setDiagnosisPosition(ConsultResult::A);
r2.setMedicalFollowUp(ConsultResult::N);
r2.setSymptomaticState(ConsultResult::Symptomatic);
r2.setSelectedCriterias(QList<int>() << 1 << 2);
r2.setHtmlCommentOnCR("<p>This the CR<b>comment</b><br></p>");
r2.setHtmlCommentOnCriterias("<p>This the criteria<b>comment</b><br></p>");
QDateTime dt = QDateTime::currentDateTime();
r2.setDateOfExamination(dt);
QTime time = dt.time();
dt.time().setHMS(time.hour(), time.minute(), time.second());
dt.setTime(time);
QString extra;
QList<ConsultResult> list = ConsultResult::fromXml(r2.toXml("<xtra>bla bla</xtra>"), &extra);
extra = extra.simplified();
QCOMPARE(list.count(), 1);
QString control = QString("<%1> <xtra>bla bla</xtra> </%1>").arg(Constants::XML_EXTRA_TAG);
QCOMPARE(extra, control);
QVERIFY(r2 == list.at(0));
QVERIFY(r2.toXml() == list.at(0).toXml());
// Test Multiple CR XML
list.clear();
for(int i=0; i<10; ++i) {
ConsultResult cr;
cr.setConsultResult(r.randomInt(1, 300));
cr.setDiagnosisPosition(ConsultResult::DiagnosisPosition(r.randomInt(0, 3)));
cr.setMedicalFollowUp(ConsultResult::MedicalFollowUp(r.randomInt(0, 2)));
cr.setSymptomaticState(ConsultResult::SymptomaticState(r.randomInt(0, 1)));
cr.setChronicDiseaseState(ConsultResult::ChronicDiseaseState(r.randomInt(0, 1)));
cr.setSelectedCriterias(QList<int>() << r.randomInt(0, 300) << r.randomInt(0, 300));
cr.setHtmlCommentOnCR(r.randomString(r.randomInt(10, 500)));
cr.setHtmlCommentOnCriterias(r.randomString(r.randomInt(10, 500)));
cr.setDateOfExamination(r.randomDateTime(QDateTime::currentDateTime().addMonths(-10)));
list << cr;
}
QString xml = ConsultResult::listToXml(list, "<xtra>bla bla</xtra>");
QList<ConsultResult> fromXmlList = ConsultResult::fromXml(xml, &extra);
QCOMPARE(list.count(), fromXmlList.count());
QCOMPARE(list, fromXmlList);
}
示例6: updateCurrentTime
void VlcWidgetSeek::updateCurrentTime(const int &time)
{
if (_lock)
return;
QTime currentTime = QTime(0,0,0,0).addMSecs(time);
QString display = "mm:ss";
if (currentTime.hour() > 0)
display = "hh:mm:ss";
_labelElapsed->setText(currentTime.toString(display));
_seek->setValue(time);
}
示例7: total_fee
double Dialog::total_fee(QTime it,QTime ot)
{
double total=0;
int i=1;
QTime et,st,t(0,0);
if(ot<it)
{
et=t;
}
else
et=ot;
QSqlQuery l;
if(et.hour()==0&&et.minute()==0)
l.exec("select *from sfsz where end_time>\'"+it.toString()+"\' or end_time='0:00' order by start_time");
else
l.exec("select *from sfsz where start_time<\'"+et.toString()+"\' and end_time>\'"+it.toString()+"\' order by end_time");
st=it;
while(l.next())
{
if(i==0)
st=l.value(0).toTime();
if(et>=l.value(1).toTime()||et==t)
{
double to=l.value(1).toTime().hour()-st.hour()+(double)(l.value(1).toTime().minute()-st.minute())/60;
if(l.value(1).toTime().hour()==0&&l.value(1).toTime().minute()==0)
{
to+=24;
}
total+=l.value(2).toDouble()*(to);
}
else
{
total+=l.value(2).toDouble()*(et.hour()-st.hour()+(double)(et.minute()-st.minute())/60);
}
i=0;
}
if(ot<it)
{
l.exec("select *from sfsz1 where start_time<\'"+ot.toString()+"\' order by start_time");
while(l.next())
{
if(ot<l.value(1).toTime()||(l.value(1).toTime().hour()==0&&l.value(1).toTime().minute()==0))
total+=l.value(2).toDouble()*(ot.hour()-l.value(0).toTime().hour()+(double)(ot.minute()-l.value(0).toTime().minute())/60);
else
total+=l.value(2).toDouble()*(l.value(1).toTime().hour()-l.value(0).toTime().hour()+(double)(l.value(1).toTime().minute()-l.value(0).toTime().minute())/60);
}
}
return total;
}
示例8: remaingTimeToString
QString DownloadItem::remaingTimeToString(QTime time)
{
if (time < QTime(0, 0, 10)) {
return tr("few seconds");
}
else if (time < QTime(0, 1)) {
return tr("%n seconds", "", time.second());
}
else if (time < QTime(1, 0)) {
return tr("%n minutes", "", time.minute());
}
else {
return tr("%n hours", "", time.hour());
}
}
示例9: re
QTime operator/(QTime l,int r)
{
//convert everything into milliseconds, devide, and convert back
int left=l.hour()*60*60*1000 + l.minute()*60*1000 + l.second()*1000 + l.msec();
int result = left/r;
int ms = result%1000;
result = (result - ms)/1000;
int s = result%60;
result = (result - s)/60;
int m = result%60;
result = (result - m)/60;
int h = result;
QTime re(h,m,s,ms);
return re;
}
示例10: AgendaException
Programmation::Programmation(const int id, const QDate &d, const QTime &dur, const QTime &h):id(id),date(d),duree(dur),horaire(h)
{
ProgManager::Iterator it = ProgManager::getInstance()->getIterator();
int jour = d.day();
/*int debut = h.hour();
int fin = debut + dur.hour();*/
QTime debut=h;
QTime fin;
fin.setHMS(h.hour()+dur.hour(),h.minute()+dur.minute(),h.second()+dur.second());
/*bool commencePendant=false;
bool terminePendant=false;*/
bool horaireinvalide=false;
bool memeJour=false;
while(it.courant() != ProgManager::getInstance()->end())
{
Programmation *p = it.valeur();
/*int pH = p->getHoraire().hour();
int pFin = pH + p->getDuree().hour();*/
int pJour = it.valeur()->getDate().day();
/* commencePendant = (debut >= pH && debut <= pFin); //On autorise qu'un evenement se finisse à une heure h et qu'un autre commence tout de suite après
terminePendant = (fin >= pH && fin <= pFin);*/
QTime pDeb=p->getHoraire();
QTime pFin;
pFin.setHMS(p->getHoraire().hour()+p->getDuree().hour(),p->getHoraire().minute()+p->getDuree().minute(),p->getHoraire().second()+p->getDuree().second());
/*commencePendant= (debut>=pDeb && debut<pFin);
terminePendant= (fin>pDeb && fin<=pFin);*/
horaireinvalide=(debut<=pDeb && fin>=pFin)
|| (debut<=pDeb && (fin<=pFin && fin>pDeb))
|| ((debut>=pDeb && debut<pFin) && fin>=pFin)
|| ((debut>=pDeb && debut<pFin) && (fin>=pDeb && fin<=pFin));
memeJour = jour == pJour;
if( memeJour && horaireinvalide)
throw AgendaException("Une programmation occupe déjà une partie de cette plage horaire");
it.next();
}
}
示例11: getDate
a1time Validity::getDate() const
{
a1time date(dateTime());
QTime time;
if (midnight) {
time = endDate ? QTime(23,59,59) : QTime(0,0,0);
date.setTimeSpec(Qt::UTC);
} else {
time = date.time();
time.setHMS(time.hour(), time.minute(), 0);
}
date.setTime(time);
return date;
}
示例12: getRandomFileName
static QString getRandomFileName(size_t length)
{
const QString possibleCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
QTime currentTime = QTime::currentTime();
qsrand(currentTime.hour() + currentTime.second() + currentTime.minute() + currentTime.msec());
QString randomString;
for(size_t i=0; i<length; ++i)
{
int index = qrand() % possibleCharacters.length();
QChar nextChar = possibleCharacters.at(index);
randomString.append(nextChar);
}
return randomString;
}
示例13: on_save_clicked
void MainWindow::on_save_clicked()
{
QTime time = QTime::currentTime();
QDate date = QDate::currentDate();
QString name;
if(date.day()<10)
name += "0";
name += QString::number(date.day())+".";
if(date.month()<10)
name += "0";
name += QString::number(date.month())+".";
name += QString::number(date.year())+"_";
if(time.hour()<10)
name += "0";
name += QString::number(time.hour())+"-";
if(time.minute()<10)
name += "0";
name += QString::number(time.minute())+"-";
if(time.second()<10)
name += "0";
name += QString::number(time.second());
QFile file(name+".png");
qDebug() << name;
file.open(QIODevice::WriteOnly);
QMessageBox msgBox;
msgBox.setStandardButtons(QMessageBox::Ok);
if(ui->outputGraph->pixmap()->save(&file,"PNG")) {
msgBox.setText("Saved to program folder with name: "+name+".png");
msgBox.setWindowTitle("Saved!");
}
else {
msgBox.setText("Error saving.");
msgBox.setWindowTitle("Error!");
}
msgBox.exec();
}
示例14: QMainWindow
ChimeryMainWindow::ChimeryMainWindow(QWidget *parent) :
QMainWindow(parent)
{
QTime currentT = QTime::currentTime();
cycButtons = new QLinkedList<QPushButton *>();
cycGaps = new QLinkedList<QSpinBox *>();
times = new QLinkedList<QDateTime *>();
QWidget * central = new QWidget(this);
setCentralWidget(central);
QGridLayout * lay = new QGridLayout(central);
central->setLayout(lay);
cycStart = new QTimeEdit(QTime(currentT.hour(), currentT.minute() - (currentT.minute() % 5) + 5), central);
cycNum = new QSpinBox(central);
cycNum->setRange(1, 12);
cycNum->setValue(8);
cycDur = new QSpinBox(central);
cycDur->setRange(5, 90);
cycDur->setValue(50);
cycDur->setSingleStep(5);
cycStartL = new QLabel("Start Time", central);
cycNumL = new QLabel("Cycles", central);
cycDurL = new QLabel("Duration", central);
gapL = NULL;
gogogo = NULL;
begin = new QSound(":art/begin.wav", this);
end = new QSound(":art/end.wav", this);
lay->addWidget(cycStartL, 0, 0, 1, 1);
lay->addWidget(cycNumL, 0, 1, 1, 1);
lay->addWidget(cycDurL, 0, 2, 1, 1);
lay->addWidget(cycStart, 1, 0, 1, 1);
lay->addWidget(cycNum, 1, 1, 1, 1);
lay->addWidget(cycDur, 1, 2, 1, 1);
adjustSize();
about = new ChimeryAboutWindow(this);
menus = new ChimeryMenus(this, about);
systray = new QSystemTrayIcon(this);
systray->setContextMenu(menus->menu);
active_icon = new QIcon(":art/chimeryactivelogo.svg");
passive_icon = new QIcon(":art/chimerylogo.svg");
QObject::connect(cycStart, SIGNAL(timeChanged(QTime)), this, SLOT(cyc()), Qt::QueuedConnection);
QObject::connect(cycNum, SIGNAL(valueChanged(int)), this, SLOT(cyc()), Qt::QueuedConnection);
QObject::connect(cycDur, SIGNAL(valueChanged(int)), this, SLOT(cyc()), Qt::QueuedConnection);
timer = new QTimer(this);
timer->setTimerType(Qt::VeryCoarseTimer);
timer->setSingleShot(true);
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(chime()), Qt::QueuedConnection);
cyc();
}
示例15: ajouterProgrammation
void Agenda::ajouterProgrammation(const TacheUnitaire & t, const QDate& d, const QTime& h){
vector <Programmation *> & listeProgrammation = trouverProgrammation(t);
// si la programmation existe déjà, on ne peut pas la programmer à nouveau
if (listeProgrammation.size() != 0 ) {
throw CalendarException("erreur ajouterProgrammation, cette fonction ne peut être appelée que si la tâche n'a jamais été programmée");
}
int minute_fin = h.minute() + t.getDuree().getMinute();
int heure_fin = h.hour() + t.getDuree().getHeure() + (minute_fin / 60) ;
minute_fin = minute_fin % 60;
if ( !QTime::isValid(heure_fin, minute_fin, 0) ) {
throw CalendarException("erreur ajouterProgrammation : une programmation ne peut pas être à cheval sur deux jours");
}
ajouterProgrammation(t, d, h, *(new QTime(heure_fin, minute_fin)) );
}