错误:"类 QComboBox"没有名为"setCurrentText"的成员;

error: ‘class QComboBox’ has no member named ‘setCurrentText’;

本文关键字:quot setCurrentText 成员 QComboBox 错误      更新时间:2023-10-16

我遇到了这样的错误,

error: ‘class QComboBox’ has no member named ‘setCurrentText’; did you mean ‘currentText’?
x_cn_num->setCurrentText(QApplication::translate("MainWindow", "0", 0, QApplication::UnicodeUTF8));
^~~~~~~~~~~~~~

但是,我检查了官方文档,"setCurrentText"完全是QComboBox的兼容成员。

如果你知道真正的原因和解决方案,请给我一些线索。

您正在尝试使用 Qt 3.0 函数。您应该使用文档中链接的替代函数(在本例中setItemText(,或者如果您确实想使用旧函数,则需要定义QT_DISABLE_DEPRECATED_BEFORE0