本文整理汇总了C++中QDateTimeEdit::setDateTimeRange方法的典型用法代码示例。如果您正苦于以下问题:C++ QDateTimeEdit::setDateTimeRange方法的具体用法?C++ QDateTimeEdit::setDateTimeRange怎么用?C++ QDateTimeEdit::setDateTimeRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTimeEdit
的用法示例。
在下文中一共展示了QDateTimeEdit::setDateTimeRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fileDialog
//.........这里部分代码省略.........
connect(buttonOpen, &QPushButton::clicked, this, [=](){
QFileDialog fileDialog(this,
tr("Open history database files"),
QApplication::applicationDirPath().append("/../data"),
tr("Data Base File (*.db *.mdb)"));
if (fileDialog.exec() == QDialog::Rejected) {
return;
}
// clear curve
curveHistory->clear();
//
QStringList filePaths = fileDialog.selectedFiles();
if (filePaths.isEmpty()) {
return;
}
QString filePath = filePaths.first();
if (filePath.isEmpty()) {
return;
}
// open database
if (!DataBaseMgr::instance().open(filePath)) {
Q_ASSERT(false);
return;
}
//
QDateTime startTime = QDateTime::fromMSecsSinceEpoch(DataBaseMgr::instance().startTime());
QDateTime endTime = QDateTime::fromMSecsSinceEpoch(DataBaseMgr::instance().endTime());
dateTimeEditStart->setDateTimeRange(startTime, endTime);
dateTimeEditEnd->setDateTimeRange(startTime, endTime);
dateTimeEditEnd->setDateTime(endTime);
dateTimeEditStart->setDateTime(startTime);
// curve title
curveHistory->setTitle(tr("History Data View")
.append(" (")
.append(QFileInfo(filePath).fileName())
.append(")"));
});
connect(buttonExport, &QPushButton::clicked, this, [=](){
QStringList filePaths = QFileDialog::getOpenFileNames(this,
tr("Convert data base files to txt format and save..."),
QApplication::applicationDirPath().append("/../data"),
tr("Data Base File (*.db *.mdb)"));
if (filePaths.isEmpty()) {
return;
}
//
if (DataBaseMgr::instance().convertToText(filePaths)) {
QMessageBox::information(this, tr("Convert Database file"), tr("Convert successfully!"));
} else {
QMessageBox::information(this, tr("Convert Database file"), tr("Convert failed!"));
}
});
connect(dateTimeEditStart, &QDateTimeEdit::dateTimeChanged, this, [=](const QDateTime &dateTime){
QDateTime endDateTime = dateTimeEditEnd->dateTime();
if (dateTime > endDateTime) {
dateTimeEditStart->setDateTime(endDateTime);
}