本文整理汇总了C++中QDateTime::currentDateTime方法的典型用法代码示例。如果您正苦于以下问题:C++ QDateTime::currentDateTime方法的具体用法?C++ QDateTime::currentDateTime怎么用?C++ QDateTime::currentDateTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTime
的用法示例。
在下文中一共展示了QDateTime::currentDateTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveAConfig
void OptionsWindow::SaveAConfig(int step, bool nomesseage = true) {
QSettings *GlobalSettings = new QSettings("/root/.WiFiHostapdAP/WiFi_Hostapd_AP.conf",QSettings::NativeFormat); // создание нового объекта
// Функция сохраения конфигурационных файлов по маске
// №1 - что сохраняем - 0 = только HOSTAPD; 1 - DNSMASQ
QString temp;
QDateTime TimeNow;
QString dateUNIXNow;
if(step == 0) {
// Сохраняем только HOSTAPD
temp = getMaskToConfig(0);
QFile::remove("/etc/hostapd/hostapd.conf");
QFile hostapd_config("/etc/hostapd/hostapd.conf");
hostapd_config.open(QIODevice::WriteOnly);
QTextStream out(&hostapd_config);
out << temp;
hostapd_config.close();
dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
emit toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("Hostapd config succesfully update."), QString("1")));
// Hostapd
if(!nomesseage) {
QMessageBox msgBoxHostapd;
msgBoxHostapd.setText(tr("Конфигурационный файл обновлён"));
msgBoxHostapd.setIcon(QMessageBox::Information);
msgBoxHostapd.setInformativeText(tr("Настройки Hostapd успешно сохранены. Для вступления их в силу, пожалуйста, перезапустите точку доступа."));
msgBoxHostapd.setStandardButtons(QMessageBox::Ok);
msgBoxHostapd.setDefaultButton(QMessageBox::Ok);
msgBoxHostapd.exec(); }
temp.clear();
} else {
// Сохраняемфайл DNSMASQ
// 1
temp = getMaskToConfig(1);
QFile::remove("/etc/dnsmasq.conf");
QFile firstDHCPConfig("/etc/dnsmasq.conf");
firstDHCPConfig.open(QIODevice::WriteOnly);
QTextStream out1(&firstDHCPConfig);
out1 << temp;
firstDHCPConfig.close();
temp.clear();
dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
emit toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("DNSMASQ config succesfully update."), QString("1")));
// DHCP
if(!nomesseage) {
QMessageBox msgBoxDHCP;
msgBoxDHCP.setText(tr("Конфигурационный файл обновлён"));
msgBoxDHCP.setIcon(QMessageBox::Information);
msgBoxDHCP.setInformativeText(tr("Настройки DHCP успешно сохранены. Для вступления их в силу, пожалуйста, перезапустите точку доступа."));
msgBoxDHCP.setStandardButtons(QMessageBox::Ok);
msgBoxDHCP.setDefaultButton(QMessageBox::Ok);
msgBoxDHCP.exec(); }
temp.clear();
}
delete GlobalSettings;
}
示例2: SaveAConfig
void OptionsWindow::SaveAConfig(int step, bool nomesseage = true) {
QSettings *GlobalSettings = new QSettings("/root/.WiFiHostapdAP/WiFi_Hostapd_AP.conf",QSettings::NativeFormat); // creating a new object
// Функция сохраения конфигурационных файлов по маске
// №1 - что сохраняем - 0 = только HOSTAPD; 1 - DNSMASQ
QString temp;
QDateTime TimeNow;
QString dateUNIXNow;
if(step == 0) {
// Save only HOSTAPD
temp = getMaskToConfig(0);
QFile::remove("/etc/hostapd/hostapd.conf");
QFile hostapd_config("/etc/hostapd/hostapd.conf");
hostapd_config.open(QIODevice::WriteOnly);
QTextStream out(&hostapd_config);
out << temp;
hostapd_config.close();
dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
emit toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("Hostapd config succesfully update."), QString("1")));
// Hostapd
if(!nomesseage) {
QMessageBox msgBoxHostapd;
msgBoxHostapd.setText(tr("The configuration file is updated"));
msgBoxHostapd.setIcon(QMessageBox::Information);
msgBoxHostapd.setInformativeText(tr("Hostapd Settings saved successfully. To enter into force, please restart the access point."));
msgBoxHostapd.setStandardButtons(QMessageBox::Ok);
msgBoxHostapd.setDefaultButton(QMessageBox::Ok);
msgBoxHostapd.exec(); }
temp.clear();
} else {
// Сохраняемфайл DNSMASQ
// 1
temp = getMaskToConfig(1);
QFile::remove("/etc/dnsmasq.conf");
QFile firstDHCPConfig("/etc/dnsmasq.conf");
firstDHCPConfig.open(QIODevice::WriteOnly);
QTextStream out1(&firstDHCPConfig);
out1 << temp;
firstDHCPConfig.close();
temp.clear();
dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
emit toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("DNSMASQ config succesfully update."), QString("1")));
// DHCP
if(!nomesseage) {
QMessageBox msgBoxDHCP;
msgBoxDHCP.setText(tr("The configuration file is updated"));
msgBoxDHCP.setIcon(QMessageBox::Information);
msgBoxDHCP.setInformativeText(tr("DHCP Settings saved successfully. To enter into force, please restart the access point."));
msgBoxDHCP.setStandardButtons(QMessageBox::Ok);
msgBoxDHCP.setDefaultButton(QMessageBox::Ok);
msgBoxDHCP.exec(); }
temp.clear();
}
delete GlobalSettings;
}
示例3: on_RestoreDHCP_clicked
void OptionsWindow::on_RestoreDHCP_clicked()
{
/* Обнуляем все значения на вкладке "DHCP" */
QMessageBox msgBox;
msgBox.setText(tr("Сброс данных"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setInformativeText(tr("Внимание! Все настройки будут сброшены до первоначальных. Продолжить?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
ui->IP_CLIENT1->setText("192.168.0.2");
ui->IP_CLIENT2->setText("192.168.0.255");
ui->Internet_iface->setCurrentIndex(0);
ui->ip_time->setCurrentIndex(2);
ui->UseGoogle->setChecked(true);
QDateTime TimeNow;
QString dateUNIXNow;
dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
emit toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("DNSMASQ settings set to default."), QString("1")));
on_DHCPSave_clicked(false);
break;
}
}
示例4: sendMessagetoBuddy
void slm_client::sendMessagetoBuddy()
{
if(m_ui->slm_client_outgoingTextArea->text() != "")
{
QDateTime currentTime;
QString shownMessage;
outGoingTextString = m_ui->slm_client_outgoingTextArea->text();
if(!m_isLastMessageSendByMe || (isCleared == 1))
{
shownMessage += "(" + currentTime.currentDateTime().toString(DATE_FORMAT) + ") " + MY_NAME + ":";
echo(HEADER,shownMessage);
isCleared = 0;
}
echo(MESSAGE,outGoingTextString);
m_isLastMessageSendByMe = true;
outGoingTextString = encryptionObject.dencrypt(outGoingTextString, this->EncryptionKey);
outGoingTextArray = outGoingTextString.toUtf8();
outgoingSocket->write(outGoingTextArray);
//clear the text field after writing the text
m_ui->slm_client_outgoingTextArea->clear();
}
}
示例5: on_RestoreProg_clicked
void OptionsWindow::on_RestoreProg_clicked()
{
/* Обнуляем все значения на вкладке "Приложение" */
QMessageBox msgBox;
msgBox.setText(tr("Сброс данных"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setInformativeText(tr("Внимание! Все настройки будут сброшены до первоначальных. Продолжить?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
ui->UpdateTraffic->setValue(1);
ui->Language->setCurrentIndex(0);
ui->ClientPriceUpdate->setValue(5);
QDateTime TimeNow;
QString dateUNIXNow;
dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
emit toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("Programm settings set to default."), QString("1")));
on_ProgSave_clicked();
break;
}
OptionsWindow::on_ProgSave_clicked();
}
示例6: on_RestoreDHCP_clicked
void OptionsWindow::on_RestoreDHCP_clicked()
{
/* Resets all values tab "DHCP" */
QMessageBox msgBox;
msgBox.setText(tr("factory reset"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setInformativeText(tr("Caution All settings will be reset to the original. proceed?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
ui->IP_CLIENT1->setText("192.168.0.2");
ui->IP_CLIENT2->setText("192.168.0.255");
ui->Internet_iface->setCurrentIndex(0);
ui->ip_time->setCurrentIndex(2);
ui->UseGoogle->setChecked(true);
QDateTime TimeNow;
QString dateUNIXNow;
dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
emit toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("DNSMASQ settings set to default."), QString("1")));
on_DHCPSave_clicked(false);
break;
}
}
示例7: on_RestoreProg_clicked
void OptionsWindow::on_RestoreProg_clicked()
{
/* Resets all values in the "application" */
QMessageBox msgBox;
msgBox.setText(tr("factory reset"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setInformativeText(tr("Caution All settings will be reset to the original. proceed?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
ui->UpdateTraffic->setValue(1);
ui->Language->setCurrentIndex(0);
ui->ClientPriceUpdate->setValue(5);
QDateTime TimeNow;
QString dateUNIXNow;
dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
emit toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("Programm settings set to default."), QString("1")));
on_ProgSave_clicked();
break;
}
OptionsWindow::on_ProgSave_clicked();
}
示例8: openLog
void cLogFile::openLog()
{
QString date = myLocaltime.currentDateTime().toLocalTime().toString("yyyyMMddhhmmss");
QString fileName = "logs/osiBS_"+date+".csv";
file.setFileName(fileName);
file.open(QIODevice::WriteOnly);
}
示例9: readMessagefromBuddy
void slm_client::readMessagefromBuddy(QString incomingMessage, QHostAddress peerAddress)
{
QDateTime currentTime;
QString shownMessage;
//decrypt the message
incomingMessage = encryptionObject.dencrypt(incomingMessage, this->EncryptionKey);
// check if the message gui is open or not and open if it is not.
if(this->getGuiKey() == 0)
{
this->show();
this->setGuiKey(1);// set the gui key to one to indicate it is opened
isFirstMessage = 1;
}
else
{
this->activateWindow();// if it is already opened, activate it before writing the message
}
//show the message to the by formatting
if(m_isLastMessageSendByMe || (isFirstMessage == 1) || (isCleared == 1))
{
shownMessage += "(" + currentTime.currentDateTime().toString(DATE_FORMAT) + ") " + m_slmclientName + ":";
echo(HEADER,shownMessage);
isFirstMessage = 0;
isCleared = 0;
}
echo(MESSAGE,incomingMessage);
m_isLastMessageSendByMe = false;
}
示例10: on_RestoreAP_clicked
void OptionsWindow::on_RestoreAP_clicked()
{
/* Обнуляем все значения на вкладке "Hostapd" */
QMessageBox msgBox;
msgBox.setText(tr("Сброс данных"));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setInformativeText(tr("Внимание! Все настройки будут сброшены до первоначальных. Продолжить?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
ui->IP_SERVER->setText("192.168.0.1");
ui->MASKA->setText("255.255.255.0");
ui->SSID->setText("MyWiFI_AP");
ui->ShowSSID->setChecked(false);
ui->driver->setCurrentIndex(1);
ui->Iface->setCurrentIndex(0);
ui->TypeAP->setCurrentIndex(0);
ui->Protection->setCurrentIndex(1);
ui->CountryCode->setCurrentIndex(0);
ui->Channels->setCurrentIndex(6);
QDateTime TimeNow;
QString dateUNIXNow;
dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t());
emit toMainLog(QString("%1|%2|%3|%4").arg(tr("Options"), dateUNIXNow, tr("Hostapd settings set to default."), QString("1")));
on_APSave_clicked(false);
break; }
}
示例11: para_ibp1
void CDatabaseModule::f_store_ibp(int chanel,int ss,int sz,int pj)
{
QSqlQuery query;
if(chanel == 1)
{
query.prepare("INSERT INTO para_ibp1 (para_id, para_value1,para_value2,para_value3,para_time,para_date,para_datetime ) "
"VALUES (:para_id, :para_value1, :para_value2,:para_value3,:para_time,:para_date,:para_datetime )");
query.bindValue(":para_id",DB_PARA_TYPE_IBP1);
}
else if(chanel == 2)
{
query.prepare("INSERT INTO para_ibp2 (para_id, para_value1,para_value2,para_value3,para_time,para_alm_flg1,para_alm_flg2,para_alm_flg3 ) "
"VALUES (:para_id, :para_value1, :para_value2,:para_value3,:para_time,:para_alm_flg1,:para_alm_flg2,:para_alm_flg3 )");
query.bindValue(":para_id",DB_PARA_TYPE_IBP2);
}
query.bindValue(":para_value1",ss);
query.bindValue(":para_value2",sz);
query.bindValue(":para_value3",pj);
bool flg = false;
query.bindValue(":para_alm_flg1",ss);
query.bindValue(":para_alm_flg2",sz);
query.bindValue(":para_alm_flg3",pj);
QDateTime time = QDateTime::currentDateTime();
QString datetime = time.currentDateTime().toString(Qt::TextDate);
QString sdate = time.toString("yyyy-MM-dd");
QString stime = time.toString("hh:mm:ss");
query.bindValue(":para_date",sdate);
query.bindValue(":para_time",stime);
query.bindValue(":para_datetime",datetime);
query.exec();
}
示例12: updateDate
void MainWindow::updateDate()
{
QDateTime date;
date = date.currentDateTime();
qDebug() << date.toString("yyyy-MM-dd");
dateSequence << date.toString("yyyy-MM-dd");
}
示例13: QDialog
CMoonCal::CMoonCal(QWidget *parent, mapView_t *view) :
QDialog(parent),
///////////////////////////////////////////////////////
ui(new Ui::CMoonCal)
{
m_img = NULL;
ui->setupUi(this);
m_moon = new QPixmap(":/res/moon_small.png");
m_sun = new QPixmap(":/res/sun_small.png");
m_isMoon = true;
QDateTime t;
t = t.currentDateTime();
m_curDay = t.date().day();
m_curMonth = t.date().month();
m_curYear = t.date().year();
jdConvertJDTo_DateTime(view->jd + view->geo.tz, &t);
m_year = t.date().year();
m_month = t.date().month();
m_img = new QImage(1, 1, QImage::Format_ARGB32);
m_view = *view;
ui->comboBox->addItem(tr("Moon"));
ui->comboBox->addItem(tr("Sun2", "Sun (not Sunday)"));
ui->comboBox->setCurrentIndex(0);
updateTime();
}
示例14: para_nibp
void CDatabaseModule::f_store_nibp(int ss,int sz,int pj)
{
QSqlQuery query;
query.prepare("INSERT INTO para_nibp (para_id, para_value1,para_value2,para_value3,para_date,para_time,para_datetime,para_alm_flg1,para_alm_flg2,para_alm_flg3 ) "
"VALUES (:para_id, :para_value1, :para_value2,:para_value3,:para_date,:para_time,:para_datetime,:para_alm_flg1,:para_alm_flg2,:para_alm_flg3 )");
query.bindValue(":para_id",DB_PARA_TYPE_NIBP);
query.bindValue(":para_value1",ss);
query.bindValue(":para_value2",sz);
query.bindValue(":para_value3",pj);
bool warningflg = true;
query.bindValue(":para_alm_flg1",warningflg);
warningflg = false;
query.bindValue(":para_alm_flg2",warningflg);
warningflg = true;
query.bindValue(":para_alm_flg3",warningflg);
QDateTime time = QDateTime::currentDateTime();
QString datetime = time.currentDateTime().toString(Qt::TextDate);
QString sdate = time.toString("yyyy-MM-dd");
QString stime = time.toString("hh:mm:ss");
query.bindValue(":para_date",sdate);
query.bindValue(":para_time",stime);
query.bindValue(":para_datetime",datetime);
query.exec();
}
示例15: showyourphrase
bool phrase::showyourphrase(int number)//当用户点击词组学习的时候调用这个函数,提供用户选择的个数
{
QSqlDatabase db=createConnection();
if(!db.isValid())return false;
QSqlQuery sql16(db);
sql16.exec("select Chinese,English from phrase where note ='unlearned' and time ='unsure'");
myphrase q;
int t=number;
int c=0;
while(sql16.next())
{
q.English=sql16.value(0).toString();
q.Chinese=sql16.value(1).toString();
q1.append(q);//直接访问这个list得到需要的数据
QDateTime time;
QString a=time.currentDateTime().toString("yyyy-MM-dd");
sql16.exec("update words set time = '"+a+"' where English='"+q.English+"'");
c=c+1;
if(c>t)//保证传给你的词组个数是用户要求的个数
{
break;
}
}
return true;
}