I have this qt application, in the header file I have
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;
};
In the Cpp file I have
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;
}
And I am getting this error :
error C2663: 'std::vector<_Ty>::push_back' : 2 overloads have no legal conversion for 'this' pointer
Thanks for your help...
int report_intro::nextId() const
is marked as const
. That specifier promises you will not alter the state/members of the class.
m_vTests.push_back(i);
violates that as you are changing m_vTests
.
You either need to drop the const
specifier from the function or declare m_vTests
as mutable
so it can be modified in const
functions.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments