Search code examples
c++qt4qtgui

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


I have met an error like this,

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

however, I checked the official documentation, "setCurrentText" is exactly a compatible member of QComboBox.

if you know the real reason and solutions, please give me some clues.


Solution

  • You are trying to use Qt 3.0 functions. You should be using the alternative functions linked in the documentation (setItemText in this case) or if you really want to use the old functions you need to define QT_DISABLE_DEPRECATED_BEFORE to 0.