本文整理汇总了C++中QDate::fromString方法的典型用法代码示例。如果您正苦于以下问题:C++ QDate::fromString方法的具体用法?C++ QDate::fromString怎么用?C++ QDate::fromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDate
的用法示例。
在下文中一共展示了QDate::fromString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
KVSO_CLASS_FUNCTION(dateTimeEdit,setDate)
{
CHECK_INTERNAL_POINTER(widget())
QString szFormat,szDate;
KVSO_PARAMETERS_BEGIN(c)
KVSO_PARAMETER("format",KVS_PT_STRING,0,szFormat)
KVSO_PARAMETER("date",KVS_PT_STRING,0,szDate)
KVSO_PARAMETERS_END(c)
QDate date;
date=date.fromString(szDate,szFormat);
((QDateTimeEdit *)widget())->setDate(date);
return true;
}
示例2: qDebug
void MainWindow::on_pushButton_3_clicked()
{
if(ui->B_NIO->text().isEmpty() || ui->S_NO->text().isEmpty()){
QMessageBox::information(this,tr("提示"),tr("不能为空"),QMessageBox::Ok);
ui->B_NIO->clear();
ui->S_NO->clear();
return;
}
QSqlQuery query;
QString s_num="";
QString b_num="";
QString o_name="";
QString o_author="";
QString o_price ="";
QString s_name="";
query.prepare("select C_NUM from COUNT where C_NO = :uid");
query.bindValue(":uid",ui->S_NO->text());
query.exec();
if(query.next()){
s_num = query.value(0).toString();
}
query.prepare("select * from BOOKS where O_ISBN = :bid");
query.bindValue(":bid",ui->B_NIO->text());
query.exec();
if(query.next()){
o_name = query.value(1).toString();
o_author = query.value(2).toString();
o_price = query.value(4).toString();
b_num = query.value(5).toString();
}
qDebug()<<s_num<<b_num;
query.prepare("SELECT S_NAME FROM STUDENTS WHERE S_NO = ?");
query.addBindValue(ui->S_NO->text());
query.exec();
if(query.next()){
s_name = query.value(0).toString();
qDebug()<<s_name;
}
if(s_num.isEmpty() || s_num.toInt() < 1){
QMessageBox::information(this,tr("提示"),tr("输入学号错误"),QMessageBox::Ok);
ui->B_NIO->clear();
ui->S_NO->clear();
return;
}
if(b_num.isEmpty() || b_num.toInt() < 1){
QMessageBox::information(this,tr("提示"),tr("输入ISBN错误"),QMessageBox::Ok);
ui->B_NIO->clear();
ui->S_NO->clear();
return;
}
int ss_num=s_num.toInt();
int bb_num=b_num.toInt();
--bb_num;
--ss_num;
QString temss = QString(tr("%1还能借%2本书")).arg(s_name).arg(ss_num);
QMessageBox::information(this,tr("提示"),temss,QMessageBox::Ok);
query.prepare("UPDATE BOOKS SET O_STORAGE = ? WHERE O_ISBN = ?");
query.addBindValue(QString::number(bb_num,10));
query.addBindValue(ui->B_NIO->text());
query.exec();
query.prepare("UPDATE COUNT SET C_NUM = ? WHERE C_NO = ?");
query.addBindValue(QString::number(ss_num,10));
query.addBindValue(ui->S_NO->text());
query.exec();
QDate date;
date=date.fromString("2012.9.1","yyyy.M.d");
//date=date.currentDate();
QString newdate=date.toString("yyyy.M.d");
qDebug()<<newdate;
int countI = ui->tableWidget->rowCount();
ui->tableWidget->insertRow(countI);
ui->tableWidget->setItem(countI,0,new QTableWidgetItem(ui->S_NO->text()));
ui->tableWidget->setItem(countI,1,new QTableWidgetItem(s_name));
ui->tableWidget->setItem(countI,2,new QTableWidgetItem(ui->B_NIO->text()));
ui->tableWidget->setItem(countI,3,new QTableWidgetItem(o_name));
ui->tableWidget->setItem(countI,4,new QTableWidgetItem(o_author));
ui->tableWidget->setItem(countI,5,new QTableWidgetItem(o_price));
ui->tableWidget->setItem(countI,6,new QTableWidgetItem(QString(tr("借出"))));
ui->tableWidget->setItem(countI,7,new QTableWidgetItem(newdate));
query.prepare("INSERT INTO BORROW (B_NO,B_ISBN,B_TIME,B_ISRENT) VALUES(?,?,?,?)");
query.addBindValue(ui->S_NO->text());
query.addBindValue(ui->B_NIO->text());
query.addBindValue(newdate);
query.addBindValue(0);
query.exec();
query.clear();
}
示例3: reaSettings
void OptionsDialog::reaSettings()
{
#ifdef Q_OS_WIN32
QSettings settings(QDir::homePath()+tr("/Application Data/")+qApp->applicationName()+".ini", QSettings::IniFormat);
#else
QSettings settings;
#endif
QDateTime today = QDateTime::currentDateTime();
QString todaytext = today.toString("yyyyMMdd");
QStringList fontS;
QFont font;
QFont defaultFont;
fontS << settings.value("Font/FileName_Settings", ui.statusbarFontComboBox->currentFont() ).toString()
<< settings.value("Font/Statistics_Settings", ui.statusbarFontComboBox->currentFont() ).toString()
<< settings.value("Font/DefaultFont", ui.fontComboBox->currentFont() ).toString();
font.fromString(fontS.at(0));
ui.statusbarFontComboBox->setCurrentFont( font );
ui.statusbarBoldCheckBox->setChecked( font.bold() );
ui.statusbarItalicCheckBox->setChecked( font.italic() );
ui.statusbarSpinBox->setValue( font.pointSize() );
defaultFont.fromString(fontS.at(2));
ui.fontComboBox->setCurrentFont( defaultFont );
ui.fontSizeSpinBox->setValue( defaultFont.pointSize() );
ui.loadOnStartCheckBox->setChecked( settings.value( "RecentFiles/OpenLastFile", true ).toBool() );
ui.saveCursorCheckBox->setChecked( settings.value( "RecentFiles/SavePosition", true ).toBool() );
if ( !ui.loadOnStartCheckBox->isChecked() )
ui.saveCursorCheckBox->setEnabled( false );
ui.editorWidthSpinBox->setMaximum( settings.value("MaxEditorWidth", 1024).toInt());
ui.editorTopSpaceSpinBox->setMaximum(settings.value("MaxEditorTopSpace", 768).toInt());
ui.editorBottomSpaceSpinBox->setMaximum(settings.value("MaxEditorBottomSpace", 1000).toInt());
ui.wordCountSpinBox->setValue( settings.value("WordCount", 0).toInt());
ui.pageCountSpinBox->setValue( settings.value("PageCountFormula", 250).toInt());
ui.fullScreenCheckBox->setChecked( settings.value("WindowState/ShowFullScreen", true).toBool() );
ui.splashScreenCheckBox->setChecked( settings.value("WindowState/ShowSplashScreen", true).toBool() );
ui.autoSaveCheckBox->setChecked( settings.value("AutoSave", false).toBool() );
ui.flowModeCheckBox->setChecked( settings.value("FlowMode", false).toBool() );
ui.scrollBarCheckBox->setChecked( settings.value("ScrollBar", true).toBool() );
ui.pageCountCheckBox->setChecked( settings.value("PageCount", false).toBool() );
ui.soundCheckBox->setChecked( settings.value("Sound", true).toBool() );
QString datetext = settings.value("Deadline", todaytext).toString();
QDate date;
QDate dateselected = date.fromString(datetext, "yyyyMMdd");
ui.calendarWidget->setSelectedDate(dateselected);
ui.editorWidthSpinBox->setValue( settings.value ("EditorWidth", 800).toInt());
ui.editorTopSpaceSpinBox->setValue( settings.value("EditorTopSpace", 0).toInt());
ui.editorBottomSpaceSpinBox->setValue( settings.value("EditorBottomSpace", 0).toInt());
ui.spinBox->setValue( settings.value("TimedWriting", 0 ).toInt());
ui.dateFormat->setText( settings.value("DateFormat", "dd MMMM yyyy dddd").toString());
ui.timeFormat->setText( settings.value("TimeFormat", "HH:MM").toString());
QPalette palette;
palette.setColor(ui.pbFontColor->backgroundRole(),
fcolor = settings.value("Colors/FontColor", "#808080" ).toString());
ui.pbFontColor->setPalette(palette);
palette.setColor(ui.pbStatusBarColor->backgroundRole(),
scolor = settings.value("Colors/StatusColor", "#202020" ).toString());
ui.pbStatusBarColor->setPalette(palette);
palette.setColor(ui.pbEditorBackColor->backgroundRole(),
bgcolor = settings.value("Colors/Background", "black" ).toString());
ui.pbEditorBackColor->setPalette(palette);
palette.setColor(ui.pbStatusBarBgColor->backgroundRole(),
sbcolor = settings.value("Colors/StatusBg", "#808080").toString());
ui.pbStatusBarBgColor->setPalette(palette);
}