本文整理汇总了C++中QTime::setHMS方法的典型用法代码示例。如果您正苦于以下问题:C++ QTime::setHMS方法的具体用法?C++ QTime::setHMS怎么用?C++ QTime::setHMS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTime
的用法示例。
在下文中一共展示了QTime::setHMS方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stamp2TS
QDateTime stamp2TS(const QString &ts)
{
if(ts.length() != 17)
return QDateTime();
int year = ts.mid(0,4).toInt();
int month = ts.mid(4,2).toInt();
int day = ts.mid(6,2).toInt();
int hour = ts.mid(9,2).toInt();
int min = ts.mid(12,2).toInt();
int sec = ts.mid(15,2).toInt();
QDate xd;
xd.setYMD(year, month, day);
if(!xd.isValid())
return QDateTime();
QTime xt;
xt.setHMS(hour, min, sec);
if(!xt.isValid())
return QDateTime();
return QDateTime(xd, xt);
}
示例2: parseLine
QVariant TrainScheduleEngine::parseLine(QString &line)
{
QMap<QString,QVariant> data;
QTime start;
QStringList cut = line.split(";");
if (cut.count() >= 5) {
QStringList HourMinute = cut[2].split(":");
start.setHMS(HourMinute[0].toInt(), HourMinute[1].toInt(), 0);
QStringList stations = cut[4].trimmed().split(QRegExp("\\s*,\\s*"));
data["type"] = cut[0].trimmed();
data["stations"] = stations;
data["start"] = start;
data["destination"] = cut[3].trimmed();
if (cut.count() >= 6) {
data["delay"] = cut[5].trimmed();
}
else {
data["delay"] = "";
}
if (cut.count() >= 7) {
// the data are a mix of Utf8 and Latin-1 characters
// so the following lines are ugly but... it works
if (cut[6][0] == 65533) {
cut[6].remove(0, 1);
}
data["comment"] = cut[6].trimmed();
} else {
data["comment"] = "";
}
}
else {
data["type"] = "Unknown";
data["start"] = start.setHMS(0,0,0);
data["destination"] = "Unknown";
data["stations"] = QStringList();
data["comment"] = "";
data["delay"] = "";
}
return data;
}
示例3: testFollowUp
void testFollowUp(){
FollowUpRecord f;
f.setConsultationRecordId(1);
f.setDetails(QString("Details string"));
QDate qd;
QTime qt;
QDateTime d;
qd.setYMD(2000,1,1);
qt.setHMS(12,12,12);
d.setDate(qd);
d.setTime(qt);
f.setDueDateTime(d);
f.setStatus(FollowUpRecord::PENDING);
if(f.getConsultationRecordId() != 1){
qDebug() << "ERROR WITH /followuprecord/consultationrecordid";
}
if(QString::compare(QString("Details string"),f.getDetails())!=0){
qDebug() << "ERROR WITH /followuprecord/details TEST";
}
if(f.getDueDateTime().date().day() != 1){
qDebug() << "ERROR WITH /followuprecord/datetime/day TEST";
}
if(f.getDueDateTime().date().month() != 1){
qDebug() << "ERROR WITH /followuprecord/datetime/month TEST";
}
if(f.getDueDateTime().date().year() != 2000){
qDebug() << "ERROR WITH /followuprecord/datetime/year TEST";
}
if(f.getDueDateTime().time().hour() != 12){
qDebug() << "ERROR WITH /followuprecord/datetime/hour TEST";
}
if(f.getDueDateTime().time().minute() != 12){
qDebug() << "ERROR WITH /followuprecord/datetime/minute TEST";
}
if(f.getDueDateTime().time().second() != 12){
qDebug() << "ERROR WITH /followuprecord/datetime/second TEST";
}
if(f.getStatus() != FollowUpRecord::PENDING){
qDebug() <<"ERROR WITH /followuprecord/status";
}
}
示例4: getDaysTime
void NetCdfConfigureDialog::getDaysTime(double minSince, QTime &time, int &days)
{
long tmpMin = (long) minSince;
long minuits = tmpMin % 60;
long tmpHours = tmpMin / 60;
long hours = tmpHours % 24;
days = (int) (tmpHours / 24);
time.setHMS(hours,minuits,0);
}
示例5: checkTime
void MainWindow::checkTime()
{
QTime currentTime = QDateTime::currentDateTime().time();
currentTime.setHMS(currentTime.hour(), currentTime.minute(), 0);
qDebug() << storage->targetTime;
if (storage->targetTime == currentTime){
storage->runAudit();
}
}
示例6: toQDateTime
const QDateTime ADBColumn::toQDateTime(int useBackup)
{
if (intDataType != FIELD_TYPE_DATETIME &&
intDataType != FIELD_TYPE_TIMESTAMP
) ADBLogMsg(LOG_WARNING, "ADBColumn::toQDate(%d) - Warning! Column is not a date", intColumnNo);
QDateTime retVal;
QDate tmpDate;
QTime tmpTime;
QString tmpQStr;
if (useBackup) tmpQStr = intOldData;
else tmpQStr = intData;
if (tmpQStr.length() == 14) {
// Its a time stamp in the form YYYYMMDDHHMMSS
tmpDate.setYMD(
tmpQStr.mid(0,4).toInt(),
tmpQStr.mid(4,2).toInt(),
tmpQStr.mid(6,2).toInt()
);
tmpTime.setHMS(
tmpQStr.mid( 8,2).toInt(),
tmpQStr.mid(10,2).toInt(),
tmpQStr.mid(12,2).toInt()
);
} else {
// Its a datetime in the form YYYY-MM-DD HH:MM:SS
tmpDate.setYMD(
tmpQStr.mid(0,4).toInt(),
tmpQStr.mid(5,2).toInt(),
tmpQStr.mid(8,2).toInt()
);
tmpTime.setHMS(
tmpQStr.mid(11,2).toInt(),
tmpQStr.mid(14,2).toInt(),
tmpQStr.mid(17,2).toInt()
);
}
retVal.setDate(tmpDate);
retVal.setTime(tmpTime);
return (const QDateTime) retVal;
}
示例7: parseTimeString
/**
* Parse a time value from the provided string.
*
* @param value The text to be parsed
* @param ok Pointer to a boolean value which will represent the success or
* failure of the parsing attempt
* @return The number of seconds after midnight in the parsed time, shown as
* a string
*/
QString Formatting::parseTimeString(const QString &value, bool *ok)
{
// check for imported blank
if (value.isEmpty()) {
*ok = true;
return "-1";
}
int length = value.length();
int firstColon = value.indexOf(':');
if (firstColon == -1) {
// assume it's a number of seconds, as used internally
int totalSeconds = value.toInt(ok);
if (!(*ok) || totalSeconds < -1 || totalSeconds > 86399) {
*ok = false;
}
return value;
}
// from here on is used only when importing
if (firstColon < 1 || length < firstColon + 3) {
*ok = false;
return value;
}
int hours = value.left(firstColon).toInt(ok);
if (!(*ok)) {
return value;
}
int minutes = value.mid(firstColon + 1, 2).toInt(ok);
if (!(*ok)) {
return value;
}
int seconds = 0;
int secondColon = value.indexOf(':', firstColon + 1);
if (secondColon != -1 && length > secondColon + 2) {
seconds = value.mid(secondColon + 1, 2).toInt(ok);
if (!(*ok)) {
return value;
}
}
if (value.indexOf("pm", 0, Qt::CaseInsensitive) != -1) {
if (hours < 12) {
hours += 12;
}
}
else if (value.indexOf("am", 0, Qt::CaseInsensitive) != -1 && hours == 12) {
hours = 0;
}
QTime time;
if (!time.setHMS(hours, minutes, seconds)) {
*ok = false;
return value;
}
QTime midnight;
int totalSeconds = midnight.secsTo(time);
*ok = true;
return QString::number(totalSeconds);
}
示例8: roundTime
QTime UtilMethods::roundTime(QTime timeVal)
{
QTime now = timeVal;
int hr = now.hour();
int min = now.minute();
min=(min<=30)?30:0;
now.setHMS(hr,min,0);
return now;
}
示例9: onConfirmButtonClicked
void DateSettings::onConfirmButtonClicked()
{
QDate date; date.setDate(m_yearWidget->value(), m_monthWidget->value(), m_dayWidget->value());
QTime time; time.setHMS(m_timeWidget->hour(), m_timeWidget->minute(), 0);
QDateTime datetime(date, time);
Q_EMIT requestSetTime(datetime);
back();
}
示例10: GetCurrentPos
QTime wgt_QVideoPlayer::GetCurrentPos() {
if (ActualPosition!=-1) {
int TimeMSec =ActualPosition-(ActualPosition/1000)*1000;
int TimeSec =int(ActualPosition/1000);
int TimeHour =TimeSec/(60*60);
int TimeMinute =(TimeSec%(60*60))/60;
QTime tPosition;
tPosition.setHMS(TimeHour,TimeMinute,TimeSec%60,TimeMSec);
return tPosition;
} else return QTime(0,0,0,0);
}
示例11: start
/*!
\internal
*/
QDateTime Event::start( bool actual ) const
{
QDateTime dt = TimeConversion::fromUTC( startUTC );
if ( actual && typ == AllDay ) {
QTime t = dt.time();
t.setHMS( 0, 0, 0 );
dt.setTime( t );
}
return dt;
}
示例12: getValueFromRow
/*!
* \fn QString MessageProgrammesDialog::getValueFromRow(int row)
* \brief Récupère les données du tableau et en fait une chaine de caractère
* \param[in] row Ligne du tableau à récuprerer
* \returns la valeur des champs de la ligne du tableau
*
*/
QString MessageProgrammesDialog::getValueFromRow(int row)
{
QString value = "";
QString str;
QTime time;
(modele->item(row,10)->data(Qt::CheckStateRole) == QVariant(Qt::Checked) ?
value +="oui " : value += "non ");
value += Tools::prepare(modele->item(row,9)->text()) + " ";
value += modele->item(row,1)->text() + " ";
value += modele->item(row,2)->text() + " ";
if(modele->item(row,8)->data(Qt::CheckStateRole) == QVariant(Qt::Checked))
value += "aleatoire";
else
{
str = modele->item(row,6)->text();
if(str != "")
{
value +="heure "+ str.split(":").at(0) + " " + str.split(":").at(1);
}
else
{
if(modele->item(row,5)->text() != "")
value += "frequence ";
else
value += "intervalle ";
int h = modele->item(row,3)->text().split(":").at(0).toInt();
int m = modele->item(row,3)->text().split(":").at(1).toInt();
time.setHMS(h,m,0);
value += time.toString("h m ");
h = modele->item(row,4)->text().split(":").at(0).toInt();
m = modele->item(row,4)->text().split(":").at(1).toInt();
time.setHMS(h,m,0);
value += time.toString("h m ");
if(modele->item(row,5)->text() != "")
value += modele->item(row,5)->text();
else
value += modele->item(row,7)->text();
}
}
return value;
}
示例13: OtrasHoras
void AddEventos::OtrasHoras()
{
QObject* obj = QObject::sender();
QRadioButton *RadioBtn = qobject_cast<QRadioButton *>(obj);
if(RadioUnaVez==RadioBtn)
{
HoratoCheckBox();
}
if(RadioCadaHora==RadioBtn)
w_AddHora->Todos();
if(RadioOtrasHoras==RadioBtn)
w_AddHora->exec();
QCheckBox *hora[24]={w_AddHora->H0,w_AddHora->H1,w_AddHora->H2,w_AddHora->H3,w_AddHora->H4,
w_AddHora->H5,w_AddHora->H6,w_AddHora->H7,w_AddHora->H8,w_AddHora->H9,
w_AddHora->H10,w_AddHora->H11,w_AddHora->H12,w_AddHora->H13,w_AddHora->H14,
w_AddHora->H15,w_AddHora->H16,w_AddHora->H17,w_AddHora->H18,w_AddHora->H19,
w_AddHora->H20,w_AddHora->H21,w_AddHora->H22,w_AddHora->H23};
int Cuantos=0;
for(int i=0;i < 24;i++)
if(hora[i]->isChecked())
Cuantos++; //averiguamos cuantos hay
if(Cuantos==1)
RadioUnaVez->setChecked(true);// SI SOLO es una hora activa radio una vez
if(Cuantos==24)
RadioCadaHora->setChecked(true);// si son todas activa radio cada hora
for(int i=0;i < 24;i++)
{
if(hora[i]->isChecked())// pone la primera hora como hora de inicio
{
QTime PrimeraHora;
int thora, tminuto, tsegundo;
thora=hora[i]->text().toInt();
tminuto=TimeHoraInicio->time().minute();
tsegundo=TimeHoraInicio->time().second();
PrimeraHora.setHMS(thora,tminuto,tsegundo);
TimeHoraInicio->setTime(PrimeraHora);
return;
}
//qDebug() <<hora[i]->text();
//qDebug() <<TimeHoraInicio->time().hour();
}
}
示例14: ReadTimeFromICPDAS
//==========================================================================================
int MainWindow::ReadTimeFromICPDAS(QString IPaddr, QDateTime *icpDT)
{
int res;
modbus_t *mb;
uint16_t tab_reg[200];
const uint number_readed_registers=6;
uint year=0;
uint month=0;
uint day=0;
uint hour=0;
uint minute=0;
uint second=0;
//inialized context
mb = modbus_new_tcp(IPaddr.toStdString().c_str(), 502);
if (mb==NULL) {return -1;}
res=modbus_connect(mb);
modbus_set_slave(mb, 1);
if (res==-1) {modbus_free(mb); return -2;}
res=modbus_read_registers(mb, 1, number_readed_registers, tab_reg);// 6 reg from 40002
if (res!=number_readed_registers){modbus_close(mb);modbus_free(mb); return -3;}
year=tab_reg[0];
month=tab_reg[1];
day=tab_reg[2];
hour=tab_reg[3];
minute=tab_reg[4];
second=tab_reg[5];
QDate dt;
dt.setDate(year,month,day);
QTime tm;
tm.setHMS(hour,minute,second);
icpDT->setDate(dt);
icpDT->setTime(tm);
modbus_close(mb);
modbus_free(mb);
return 1;
}
示例15: getCurrentFileInfo
bool QUnZip::getCurrentFileInfo(QString &name,
QDateTime *t /* = NULL */) {
if (!isOpen()) {
qWarning("QUnZip::getCurrentFileInfo File not open.");
return false;
}
name = "";
unz_file_info fi;
if (::unzGetCurrentFileInfo(_d->_unzFile, &fi,
NULL, 0 , NULL, 0, NULL, 0) != UNZ_OK) {
qWarning("QUnZip::getCurrentFileInfo 1st unzGetCurrentFileInfo failed.");
return false;
}
char *nt;
if (fi.size_filename > 0) {
nt = new char[fi.size_filename];
Q_CHECK_PTR(nt);
} else
nt = NULL;
if (::unzGetCurrentFileInfo(_d->_unzFile, &fi,
nt, fi.size_filename,
NULL, 0,
NULL, 0)
!= UNZ_OK) {
if (nt)
delete []nt;
qWarning("QUnZip::getCurrentFileInfo 2nd unzGetCurrentFileInfo failed.");
return false;
}
if (nt) {
name.setLatin1(nt, fi.size_filename);
delete[] nt;
}
if (t != NULL) {
QDate d; QTime tt;
tt.setHMS(fi.tmu_date.tm_hour,
fi.tmu_date.tm_min, fi.tmu_date.tm_sec);
d.setYMD(fi.tmu_date.tm_year,
fi.tmu_date.tm_mon+1, fi.tmu_date.tm_mday);
*t = QDateTime(d, tt);
}
return true;
}