vitalic
5th May 2020, 19:32
Hallo,
I design a DAB app. Stations can be selected via pushbutton and if the right png file exists, the station logo is shown in the button(stretched to fill the button). It works but doesn't look that nice.
13430
The code for each button looks like this (I'm sure it can be done better, but still learning ab Qt and C++...)
if(dab_found_favs.size() >= 2){
ui->btn_dab_st02->setEnabled(true);
QString btn_sid = dab_vec_vec[dab_found_favs.at(1)][2];
bool dab_logo_exist {MainWindow::dab_logo_exists(btn_sid)};
if(dab_logo_exist == true){
ui->btn_dab_st02->setText("");
QString dab_logo = path_dab_icons + btn_sid + ".png";
QPixmap pixmap(dab_logo);
QIcon ButtonIcon(pixmap);
ui->btn_dab_st02->setIcon(ButtonIcon);
ui->btn_dab_st02->setIconSize(pixmap.rect().size());
} else {
ui->btn_dab_st02->setText(dab_vec_vec[dab_found_favs.at(1)][0]);
}
} else if(dab_found_favs.size() < 2){
ui->btn_dab_st02->setIcon(QIcon());
ui->btn_dab_st02->setEnabled(false);
ui->btn_dab_st02->setText("no favorite\navailable");
}
How can i make the corners rounded? Already tried with QPainter, but it only drew a border with rounded corners on top of the picture.
I design a DAB app. Stations can be selected via pushbutton and if the right png file exists, the station logo is shown in the button(stretched to fill the button). It works but doesn't look that nice.
13430
The code for each button looks like this (I'm sure it can be done better, but still learning ab Qt and C++...)
if(dab_found_favs.size() >= 2){
ui->btn_dab_st02->setEnabled(true);
QString btn_sid = dab_vec_vec[dab_found_favs.at(1)][2];
bool dab_logo_exist {MainWindow::dab_logo_exists(btn_sid)};
if(dab_logo_exist == true){
ui->btn_dab_st02->setText("");
QString dab_logo = path_dab_icons + btn_sid + ".png";
QPixmap pixmap(dab_logo);
QIcon ButtonIcon(pixmap);
ui->btn_dab_st02->setIcon(ButtonIcon);
ui->btn_dab_st02->setIconSize(pixmap.rect().size());
} else {
ui->btn_dab_st02->setText(dab_vec_vec[dab_found_favs.at(1)][0]);
}
} else if(dab_found_favs.size() < 2){
ui->btn_dab_st02->setIcon(QIcon());
ui->btn_dab_st02->setEnabled(false);
ui->btn_dab_st02->setText("no favorite\navailable");
}
How can i make the corners rounded? Already tried with QPainter, but it only drew a border with rounded corners on top of the picture.