td
17th August 2009, 12:28
Hi,
I have a qwidget, that has as a member a 2-D array of ints. Now I'm having trouble accessing the vales in member functions of the widget.
// the .h file
class holdingWidget : public QWidget
{
Q_OBJECT
.
.
.
.
protected:
void paintEvent(QPaintEvent *ev);
private:
int myArrayOne[44][3];
Now in the class defintion
holdingWidget::holdingWidget(QWidget* parent): QWidget(parent)
{
int myArrayOne[44][3] =....
.
.
.
}
void holdingWidget::paintEvent(QPaintEvent *ev)
{
.
.
int k = myArrayOne[0][0];
int l = myArrayOne[0][1];
}
Now in the paintEvent the values are nonsense numbers and not the ones I specified above. But if I define the array in the paintevent it works ok. What am I missing here? Any help appreciated.
I have a qwidget, that has as a member a 2-D array of ints. Now I'm having trouble accessing the vales in member functions of the widget.
// the .h file
class holdingWidget : public QWidget
{
Q_OBJECT
.
.
.
.
protected:
void paintEvent(QPaintEvent *ev);
private:
int myArrayOne[44][3];
Now in the class defintion
holdingWidget::holdingWidget(QWidget* parent): QWidget(parent)
{
int myArrayOne[44][3] =....
.
.
.
}
void holdingWidget::paintEvent(QPaintEvent *ev)
{
.
.
int k = myArrayOne[0][0];
int l = myArrayOne[0][1];
}
Now in the paintEvent the values are nonsense numbers and not the ones I specified above. But if I define the array in the paintevent it works ok. What am I missing here? Any help appreciated.