I need a frame of an arbitrary form, with background of a solid color or texture. I would like to draw everything with primitives. I've done it this way:
{
}
{
QPen pen
(Qt
::blue,
20, Qt
::SolidLine, Qt
::RoundCap, Qt
::RoundJoin);
painter.setPen(pen);
QRect rectangle
(option.
rect.
x(), option.
rect.
y(), option.
rect.
width()-10,option.
rect.
height()-10);
painter.drawRoundRect(rectangle,10,10);
}
myView::myView(QWidget *parent)
: QListView(parent)
{
}
void myView::paintEvent(QPaintEvent *event)
{
QStyleOptionViewItem option = viewOptions();
QPainter painter(viewport());
QPen pen(Qt::blue, 20, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
painter.setPen(pen);
QRect rectangle(option.rect.x(), option.rect.y(), option.rect.width()-10,option.rect.height()-10);
painter.drawRoundRect(rectangle,10,10);
QListView::paintEvent(event);
}
To copy to clipboard, switch view to plain text mode
Both items and my rectangular can be drawn. But instead of the rectangular of the QListView size, a little area of blue color appears in the upper right corner. This blue piece scrolls with my list, however, I need to replace the standard border of QListView with my frame. What's wrong?
Bookmarks