bnosam
7th April 2015, 02:41
I'm creating an array of widgets and I'm trying to add them to the main layout but I get an error.
QLabel *colorBoxes = new QLabel[numLights];
for(int i = 0; i < numLights; i++)
{
colorBoxes[i].setText(description[i]);
ui->mainLayout->addWidget(colorBoxes[i]);
}
It says it can't convert QLabel to QWidget*. It worked before in another project, I have no idea why this is doing it now?
apparently to make it work, I needed to add it as
ui->mainLayout->addWidget(colorBoxes[i].window());
QLabel *colorBoxes = new QLabel[numLights];
for(int i = 0; i < numLights; i++)
{
colorBoxes[i].setText(description[i]);
ui->mainLayout->addWidget(colorBoxes[i]);
}
It says it can't convert QLabel to QWidget*. It worked before in another project, I have no idea why this is doing it now?
apparently to make it work, I needed to add it as
ui->mainLayout->addWidget(colorBoxes[i].window());