Hi,
I'm having trouble using border-radius, in that it doesn't clip the background.
I am using QLabel as a renderer onto a listview using a delegate:
const QWidget *widget
= opt.
widget;
QRect textRect
= style
->subElementRect
(QStyle::SE_ItemViewItemText,
&opt
);
lbl.setObjectName("Godzilla");
painter->save();
painter->translate(textRect.topLeft());
lbl.setText("Godzilaaaaaaaaaaaaa");
lbl.render(painter);
painter->restore();
}
void MyDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const {
const QWidget *widget = opt.widget;
QStyle *style = widget ? widget->style() : QApplication::style();
QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &opt);
QLabel lbl;
lbl.setObjectName("Godzilla");
painter->save();
painter->translate(textRect.topLeft());
lbl.setText("Godzilaaaaaaaaaaaaa");
lbl.render(painter);
painter->restore();
}
To copy to clipboard, switch view to plain text mode
My stylesheet is:
#Godzilla {
border-radius: 5px;
background: rgba(255,0,0,80);
border: 2px solid red;
color: white;
font-weight: bold;
font-size: 10px;
}
#Godzilla {
border-radius: 5px;
background: rgba(255,0,0,80);
border: 2px solid red;
color: white;
font-weight: bold;
font-size: 10px;
}
To copy to clipboard, switch view to plain text mode
The stylesheet is loaded using qApp->setStyleSheet(..);
The style applies (color, border, background), but, the background doesn't clip.
I've tried using
setAttribute(Qt::WA_NoSystemBackground,true);
setAttribute(Qt::WA_NoSystemBackground,true);
To copy to clipboard, switch view to plain text mode
but it just prevents the background and borders from drawing at all.
I am using Qt 4.7 on Windows XP.
TIA
Bookmarks