if i want to keep a unsigned for each label:
@
struct Card{
QLabel ilabel;
unsigned status;
};
class PlayForm : public QDialog {
Q_OBJECT
Card* ImageMatrix;
public:
PlayForm();
virtual ~PlayForm();
public slots:
void Pause();
void Quit();
private:
Ui::PlayForm widget;
};
@
In the constructor:
@
PlayForm::PlayForm() {
widget.setupUi(this);
ImageMatrix = new Card[9];
int X = 70, Y = 30;
for(int i = 0; i < 9; i++){
ImageMatrix[i].ilabel = new QLabel(this);
ImageMatrix[i].ilabel.setObjectName(QString::fromUtf8("label_" + i));
ImageMatrix[i].ilabel.setGeometry(X,Y,81,121);
ImageMatrix[i].ilabel.setPixmap(QPixmap(QString::fromUtf8("dist/Debug/GNU-Linux-x86/retro_3.png")));
if(X < 310)
X += 120;
else{
X = 70;
if(Y < 310)
Y += 140;
else
Y = 30;
}
}
}
@
Error:
@
PlayForm.cpp:16:48: error: no match for ‘operator=’ in ‘(((PlayForm*)this)->PlayForm::ImageMatrix + ((long unsigned int)(((long unsigned int)i) * 48ul)))->Card::ilabel = (QFlagsQt::WindowType(0u), (operator new(40u), (<statement>, ((QLabel*)<anonymous>))))’
PlayForm.cpp:16:48: note: candidate is:
/usr/include/qt4/QtGui/qlabel.h:165:5: note: QLabel& QLabel::operator=(const QLabel&)
/usr/include/qt4/QtGui/qlabel.h:165:5: note: no known conversion for argument 1 from ‘QLabel*’ to ‘const QLabel&’
@
Why the same error?
EDIT:
It works now, here the new code of the constructor:
@
PlayForm::PlayForm() {
widget.setupUi(this);
ImageMatrix = new Card[16];
int X = 70, Y = 30;
for(int i = 0; i < 16; i++){
ImageMatrix[i].ilabel = new QLabel(this);
ImageMatrix[i].ilabel -> setObjectName(QString::fromUtf8("label_" + i));
ImageMatrix[i].ilabel -> setGeometry(X,Y,81,121);
ImageMatrix[i].ilabel -> setPixmap(QPixmap(QString::fromUtf8("dist/Debug/GNU-Linux-x86/retro_3.png")));
//QObject::connect(ImageMatrix[i].ilabel, SIGNAL(clicked()), this, SLOT(Modifica(i)));
ImageMatrix[i].status = 0; //Coperta
if(X < 430)
X += 120;
else{
X = 70;
if(Y < 450)
Y += 140;
else
Y = 30;
}
}
}
@