I have declared a QSpinBox in the constructor of a dialog like this

QSpinBox *recordNumberSpinBox = new QSpinBox;

and also declared it as public: in the header file.

But im getting core dumps when i try to do anythting with this QSpinBox in any other methods.

for instance setting a maximum

recordNumberSpinBox->setMaximum(5); in the method

void Dialog:penDataFile(QFileInfo &fileInfo){
....
}

Am i confused in thinking that setting this to public means any method can access it and that its been set globaly?