我有这个qt应用程序,在我的头文件中
class report_intro: public QWizardPage
{
Q_OBJECT
public:
report_intro(QWidget *parent = 0);
~report_intro(void);
int nextId() const;
private:
Ui::Rep_Wiz_Intro ui;
QWidget *pWnd;
std::vector<int> m_vTests;
int m_iNumTest;
};
在我的Cpp文件中
int report_intro::nextId() const
{
int i;
// check to see which check box was checked
for (i=1; i<m_iNumTest; i++)
{
QString str = QString("checkBox_T%1").arg(i);
if ((ui.groupBox_tests->findChild<QCheckBox *>(str))->isChecked())
m_vTests.push_back(i); // **** here is the error****
}
return newreport::report_page;
}
我收到这个错误:
error C2663: 'std::vector<_Ty>::push_back' : 2 overloads have no legal conversion for 'this' pointer
感谢您的帮助...
最佳答案
int report_intro::nextId() const
被标记为 const
。该说明符 promise 您不会更改类的状态/成员。
m_vTests.push_back(i);
在您更改 m_vTests
时违反了这一点。
您需要从函数中删除 const
说明符或将 m_vTests
声明为 mutable
以便它可以在 const 中修改
函数。
关于c++ - 标准 vector push_back' : 2 overloads have no legal conversion for 'this' pointer error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36651084/