I'm creating an array of widgets and I'm trying to add them to the main layout but I get an error.
for(int i = 0; i < numLights; i++)
{
colorBoxes[i].setText(description[i]);
ui->mainLayout->addWidget(colorBoxes[i]);
}
QLabel *colorBoxes = new QLabel[numLights];
for(int i = 0; i < numLights; i++)
{
colorBoxes[i].setText(description[i]);
ui->mainLayout->addWidget(colorBoxes[i]);
}
To copy to clipboard, switch view to plain text mode
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());
ui->mainLayout->addWidget(colorBoxes[i].window());
To copy to clipboard, switch view to plain text mode
Bookmarks