当前位置: 首页>>代码示例>>C++>>正文


C++ QTime::second方法代码示例

本文整理汇总了C++中QTime::second方法的典型用法代码示例。如果您正苦于以下问题:C++ QTime::second方法的具体用法?C++ QTime::second怎么用?C++ QTime::second使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTime的用法示例。


在下文中一共展示了QTime::second方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: paint

void Clock::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
    QTime time = QTime::currentTime();
    int w = this->size().width();
    int h = this->size().height();

    painter->save();
    painter->setRenderHint(QPainter::Antialiasing, true);
    //painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
    //painter->setRenderHint(QPainter::HighQualityAntialiasing , true);

    painter->translate(w/2.0, h/2.0);

    painter->drawPixmap(-mClockPix->width()/2.0, -mClockPix->height()/2.0, mClockPix->width(), mClockPix->height(), *mClockPix);

    painter->save();
    painter->rotate(30.0 * (time.hour() + time.minute() / 60.0));
    painter->drawPixmap(-mHourPix->width()/2.0, -mHourPix->height()+4 , mHourPix->width(), mHourPix->height(), *mHourPix);
    painter->restore();

    qreal a = 6.0 * time.minute();
    if (mShowSeconds)
        a += time.second() * 0.1;

    painter->save();
    painter->rotate(a);
    painter->drawPixmap(-mMinutePix->width()/2.0 , -mMinutePix->height()+3 , mMinutePix->width(), mMinutePix->height(), *mMinutePix);
    painter->restore();

    if (mShowSeconds)
    {
        painter->save();
        painter->rotate(6.0 * (time.second() /*+ time.msec() / 1000.0*/));
        painter->setPen(QColor(211, 48, 47));
        painter->drawLine(0, 0, 0, -80);
        painter->restore();
    }

    painter->drawPixmap(-mCenterPix->width()/2.0, -mCenterPix->height()/2.0, mCenterPix->width(), mCenterPix->height(), *mCenterPix);
    painter->restore();
}
开发者ID:B-Rich,项目名称:razor-qt,代码行数:41,代码来源:clock.cpp

示例2: getData

QByteArray USKTimePacket::getData()
{
    QByteArray array;
    //array.append((char)0x05); //установлены флаги F4 и F6
    //array.append((char)0x40); //установлен флаг F1
    array.append((char)0x44); //установлены флаги F1 и F5
    array.append(0x07); //7 байт данных
    quint8 l,h;
    QTime time = ui->dateTimeEdit->time();
    QDate date = ui->dateTimeEdit->date();

    l = time.second()%10;
    h = time.second()/10;
    h = h << 4;
    l |= h;
    array.append(l); //секунды

    l = time.minute()%10;
    h = time.minute()/10;
    h = h << 4;
    l |= h;
    array.append(l); //минуты

    l = time.hour()%10;
    h = time.hour()/10;
    h = h << 4;
    l |= h;
    array.append(l); //часы

    l = date.dayOfWeek();
    array.append(l); // день недели

    l = date.day() % 10;
    h = date.day() / 10;
    h = h << 4;
    l |= h;
    array.append(l); // дата

    l = date.month() % 10;
    h = date.month() / 10;
    h = h << 4;
    l |= h;
    array.append(l); // месяц

    l = (date.year() % 100) % 10;
    h = (date.year() % 100) / 10;
    h = h << 4;
    l |= h;
    array.append(l); // год

    //array.append((char)0x00); //0 повторов
    return array;
}
开发者ID:KurlesHS,项目名称:USK_Utils,代码行数:53,代码来源:usktimepacket.cpp

示例3:

TimeStamp::TimeStamp ( const QTime& tm, bool isLocal )
{
	initDefault();
	m_zone="UTC";
	QDate dt=QDate::currentDate();
	m_year=dt.year();m_month=dt.month();m_day=dt.day();
	m_hour=tm.hour();m_min=tm.minute();m_sec=tm.second();m_msec=tm.msec();
	if(isLocal)
		moveToZone(defaultzone);
	else
		moveToZone("UTC");
}
开发者ID:Nikoli,项目名称:qlandkartegt,代码行数:12,代码来源:tzdata.cpp

示例4: slotCurrentTime

void TimeToolBar::slotCurrentTime()
{
    QDateTime now = QDateTime::currentDateTime().toUTC();
    QDate d = now.date();
    QTime t = now.time();
    astro::Date celDate(d.year(), d.month(), d.day());
    celDate.hour = t.hour();
    celDate.minute = t.minute();
    celDate.seconds = (double) t.second() + t.msec() / 1000.0;

    appCore->getSimulation()->setTime(astro::UTCtoTDB(celDate));
}
开发者ID:Habatchii,项目名称:celestia,代码行数:12,代码来源:qttimetoolbar.cpp

示例5: initForm

void frmBarRuler::initForm()
{
    //初始化随机数种子
    QTime t = QTime::currentTime();
    qsrand(t.msec() + t.second() * 1000);

    QTimer *timer = new QTimer(this);
    timer->setInterval(2000);
    connect(timer, SIGNAL(timeout()), this, SLOT(updateValue()));
    timer->start();
    updateValue();
}
开发者ID:nameqiaohe,项目名称:quc,代码行数:12,代码来源:frmbarruler.cpp

示例6: srand

// start lvk
AIMLParser::AIMLParser(const QString &xml, QIODevice *logDevice)
{
    _indent = 0;
    _root.parent = NULL;
    QTime currentTime = QTime::currentTime();
    int val = currentTime.msec() + currentTime.second() + currentTime.minute();
    srand(val);

    _logStream.setDevice(logDevice);

    loadAimlFromString(xml);
}
开发者ID:devartis,项目名称:chatbot,代码行数:13,代码来源:aimlparser.cpp

示例7: paintEvent

/**
 * @brief DigitalClock::paintEvent draw the second
 */
void DigitalClock::paintEvent(QPaintEvent *)
{
     QRectF rectangle(15.0, 90.0, 310.0, 310.0);
     int startAngle = 90 * 16;
     QTime timeM = QTime::currentTime();

     int spanAngle = 6 * timeM.second() * 16;

     QPainter painter(this);
     painter.setPen(*pen);
     painter.drawArc(rectangle, startAngle, spanAngle);
}
开发者ID:AmarOk1412,项目名称:RORIV2,代码行数:15,代码来源:DigitalClock.cpp

示例8: CalendarToJd

/*! Convert a Qt4 date-time object to a Julian date.
 *
 *  TODO: leap seconds are not handled by Qt4 yet.
 *  TODO: milliseconds are not handled in the calendarTOjulian function yet.
 */
double sta::CalendarToJd(QDateTime calendarDate)
{
    Q_ASSERT(calendarDate.isValid());
    
    // Convert the timespec to UTC
    // QDateTime utcDate = calendarDate.toUTC();  // We assume for the time being that all times are UTC
    QDateTime utcDate = calendarDate;
    QDate d = utcDate.date();
    QTime t = utcDate.time();
    
    return calendarTOjulian(d.year(), d.month(), d.day(), t.hour(), t.minute(), t.second());
}
开发者ID:sanyaade-embedded-systems,项目名称:STA,代码行数:17,代码来源:date.cpp

示例9: setModelData

void TrackDelegate::setModelData(QWidget *editor,
                                 QAbstractItemModel *model,
                                 const QModelIndex &index) const
{
    if (index.column() == durationColumn) {
        QTimeEdit *timeEdit = qobject_cast<QTimeEdit *>(editor);
        QTime time = timeEdit->time();
        int secs = (time.minute() * 60) + time.second();
        model->setData(index, secs);
    } else {
        QItemDelegate::setModelData(editor, model, index);
    }
}
开发者ID:Hotwill,项目名称:qt5-book-code,代码行数:13,代码来源:trackdelegate.cpp

示例10: showTime

void workclock::showTime()
{
     QTime time = QTime::currentTime();

     QString text = time.toString("hh:mm:ss");
     if ((time.second() % 2) == 0)

         text[2] = ' ';
     else
         text[5] = ' ';

     ui->time->display(text);
     if (works==true)
     {
         if (setminute!=time.second())
         {
            setminute=time.second();
            if (value!=0) value--;
         }
     }

    if (value==15)
    {
         // QApplication::alert ( this, 1000 );
            int n = QMessageBox::warning(0,
      "Warning",
      "Pleaes Stop",
      QMessageBox::Yes | QMessageBox::No,
      QMessageBox::Yes
      );
         if (n == QMessageBox::Yes) {
      // Saving the changes!
      }
    }


    ui->workminut->display(value);

}
开发者ID:kvintagav,项目名称:workclock,代码行数:39,代码来源:workclock.cpp

示例11: gd_checkMainTime

QTime NetworkConnection::gd_checkMainTime(TimeSystem s, const QTime & t)
{
	if(s == canadian)
	{
//		int seconds = (t.minute() * 60) + t.second();
		if(t.second())
		{
//			seconds = (t.minute() * 60);
			return QTime(0, t.minute(), 0);
		}
	}
	return t;
}
开发者ID:EPeillard,项目名称:qgo,代码行数:13,代码来源:networkconnection.cpp

示例12: showTime

void DigitalClock::showTime()
{
    QTime time = QTime::currentTime();
    QString text = time.toString("h:m:s");
qDebug() << text;
    if ((time.second() % 2) == 0) {
        //text[3] = ' ';
    }
    
    display(text);

    //display("1234567890");
}
开发者ID:panweiping3,项目名称:programming,代码行数:13,代码来源:digitalclock.cpp

示例13: timerEvent

 void timerEvent(QTimerEvent *)
 {
     QTime now = QTime::currentTime();
     if (now.second() == 59 && now.minute() == time.minute() && now.hour() == time.hour()) {
         // just missed time tick over, force it, wait extra 0.5 seconds
         time.addSecs(60);
         timer.start(60500, this);
     } else {
         time = now;
         timer.start(60000-time.second()*1000, this);
     }
     emit timeChanged();
 }
开发者ID:2gis,项目名称:2gisqt5android,代码行数:13,代码来源:plugin.cpp

示例14: GetShowNowTime

void SleepReminder::GetShowNowTime()
{
	QTime now = QDateTime::currentDateTime().time();
	ui.MaoNowTime->setText(QString::number(now.hour()) + ':' +
							QString::number(now.minute()) + ':' +
							QString::number(now.second()));

	if (true == isWork)
	{
		if (ui.MaoHour->text().toInt() == now.hour() &&
			ui.MaoMinute->text().toInt() == now.minute())
			warn.start(520);
	}
}
开发者ID:MaoJianwei,项目名称:SleepReminder_Alarm,代码行数:14,代码来源:sleepreminder.cpp

示例15: 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++;
    }
开发者ID:mjc-ermont,项目名称:2011,代码行数:14,代码来源:fileimportdialog.cpp


注:本文中的QTime::second方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。