Qt QDateTimeEdit为空,消息为QLineEdit::setSelection:起始位置无效(5)
这会发生在其他人身上吗?我可以问一下这里发生了什么吗?对我来说很有用,这段代码是否为您显示了错误,或者它只是从另一个函数/类复制粘贴的?使用{QDateTimeEdit::setDisplayFormat()}@techneaz设置输入格式,我做了dateTimeEdit->setDisplayFormat(“dd/MM/yyyy”);但这并没有改变什么。我没抓住重点?@Miki,是的,这段代码在这里给出了错误。你上面粘贴的代码对我也适用,没有错误。什么是Qt版本?对我来说是有效的,这段代码是否为您显示了错误,或者它只是从另一个函数/类复制粘贴的?使用{QDateTimeEdit::setDisplayFormat()}@techneaz设置输入格式,我做了dateTimeEdit->setDisplayFormat(“dd/MM/yyyy”);但这并没有改变什么。我没抓住重点?@Miki,是的,这段代码在这里给出了错误。你上面粘贴的代码对我也适用,没有错误。什么是Qt版本?Qt QDateTimeEdit为空,消息为QLineEdit::setSelection:起始位置无效(5),qt,Qt,这会发生在其他人身上吗?我可以问一下这里发生了什么吗?对我来说很有用,这段代码是否为您显示了错误,或者它只是从另一个函数/类复制粘贴的?使用{QDateTimeEdit::setDisplayFormat()}@techneaz设置输入格式,我做了dateTimeEdit->setDisplayFormat(“dd/MM/yyyy”);但这并没有改变什么。我没抓住重点?@Miki,是的,这段代码在这里给出了错误。你上面粘贴的代码对我也适用,没有错误。什么是Qt版本?对我来说是有效的,这段代码是否
#include <QApplication>
#include <QWidget>
#include <QDateTimeEdit>
#include <QVBoxLayout>
#include <QDate>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *w = new QWidget;
QVBoxLayout *vLayout = new QVBoxLayout(w);
QDate date(2014, 6, 19);
QDateTimeEdit *dateTimeEdit = new QDateTimeEdit((QDateTime)date);
vLayout->addWidget(dateTimeEdit);
w->show();
return a.exec();
}
QLineEdit::setSelection: Invalid start position (5)