Okay I got a little closer. I found out that the QGroupBox got an checkbox that could be activated and that I will use as my radio button. To display the data I used a label and filled the label text with an html table:
QString rowLabel
[] = {"Loc.",
"Temp.",
"Hum."};
int rowData[] = {stations[index].loc, stations[index].temp, stations[index].hum};
QString tabel
= "<html><body><table>";
for(int r= 0; r<3; r++){
tabel.
append("<tr><td>"+rowLabel
[r
]+"</td><td>"+QString::number(rowData
[r
])+"</td></tr>");
}
tabel.append("</table></body></html>");
ui->propLabel->setText(tabel);
QString rowLabel[] = {"Loc.", "Temp.", "Hum."};
int rowData[] = {stations[index].loc, stations[index].temp, stations[index].hum};
QString tabel = "<html><body><table>";
for(int r= 0; r<3; r++){
tabel.append("<tr><td>"+rowLabel[r]+"</td><td>"+QString::number(rowData[r])+"</td></tr>");
}
tabel.append("</table></body></html>");
ui->propLabel->setText(tabel);
To copy to clipboard, switch view to plain text mode
That works very nice. Also I was able to set an background image to the QGroupBox using
ui->groupBox->setStyleSheet("background-image: url(:/images/bg.png)");
ui->propLabel->setStyleSheet("background-image: url()");
ui->groupBox->setStyleSheet("background-image: url(:/images/bg.png)");
ui->propLabel->setStyleSheet("background-image: url()");
To copy to clipboard, switch view to plain text mode
Unfortunately the fist line also sets a background for the label so I had to insert the second line to get rid of it again. Also the background needs to be the exact same size as the group box, otherwise the background will be repeated. I guess there is code to prevent this but I haven't found that, yet.
To update the date in my group box I can run the first script again and the data is updated.
So this is very nice already but the group box is an element that I placed in the main window. On start up it is empty and gets filled when the data is loaded. I guess I could just place several of these boxes now in my main window but since they are all the same I hoped I could create a class with all these elements and create as many objects as needed.
Just talking about the one box. How could I create this one box in a different file than mainwindow.cpp and load it into mainwindow on start up? The create new dialog from Qt Creator offers several options but I have no clue which to choose...
Bookmarks