【发布时间】:2019-03-06 09:52:21
【问题描述】:
我正在使用qt,我正在尝试使用QInputDialog::getText() 函数从用户那里获取输入,从Documentation 函数的定义是:
QString QInputDialog::getText(QWidget * parent, const QString & title, const QString & label, QLineEdit::EchoMode mode = QLineEdit::Normal, const QString & text = QString(), bool * ok = 0, Qt::WindowFlags flags = 0, Qt::InputMethodHints inputMethodHints = Qt::ImhNone)
这是我的代码:
bool ok=0;
newAddress = QInputDialog::getText(0,"Enter an Address to Validate",
"Adress: comma separated (e.g Address line 1, Address line 2, City, Postal Code)"
,&ok);
但我得到了错误:
error: no matching function for call to 'QInputDialog::getText(int, const char [29], const char [80], bool*)'
,&ok);
^
但是当我在 *ok 参数之前传递所有参数时,例如:
bool ok=0;
newAddress = QInputDialog::getText(0,"Enter an Address to Validate",
"Adress: comma separated (e.g Address line 1, Address line 2, City, Postal Code)"
,QLineEdit::Normal,
QString(),&ok);
它有效。
我真的不明白为什么我不能只更改我想要的默认参数并将其余参数保留为默认值?。
【问题讨论】: