How to get QFrame:ainter ?
How to get QFrame:ainter ?
What is that?
I meant something like:
Qt Code:
listView->setLineWidth(5);To copy to clipboard, switch view to plain text mode
J-P Nurmi
It I did already.
now I need to draw on a background QListView.
How?
if i do
i get painter from QAbstractItemView and my text scroll with item.Qt Code:
{ } { painter.drawText(rect(),Qt::AlignLeft,"Test DRive this List"); }To copy to clipboard, switch view to plain text mode
it follows from this that it is needed to draw on painter from QFrame or QWidget
Last edited by someralex; 19th December 2006 at 19:18.
I'm not sure if this works with QWindowsXpStyle but works with QPlastiqueStyle, at least. Set QPalette::Base brush to Qt::transparent:
Qt Code:
listView->setPalette(p);To copy to clipboard, switch view to plain text mode
And in this case draw before passing the paint event to the base class implementation.
J-P Nurmi
So you want the drawing to stay in corresponding place at background when scrolling?
Qt Code:
painter.translate(-horizontalScrollBar()->value(), -verticalScrollBar()->value()); painter.drawSomething(...);To copy to clipboard, switch view to plain text mode
J-P Nurmi
this code work
but :Qt Code:
painter.setPen(pen); painter.drawRect(rect()); painter.translate(-horizontalScrollBar()->value(), -verticalScrollBar()->value());To copy to clipboard, switch view to plain text mode
1.at scrolling of list, top and bottom lines of rectangle erase.If using painter.translate identical effect
2.rectangle paint over item
Translate first, then draw. Translating the painter after painting has no effect. The default QItemDelegate painting implementation fills items' background with QPalette::Base. That's why I told you to use a transparent brush.
J-P Nurmi
after using
all ok. ThanksQt Code:
listView->setPalette(p);To copy to clipboard, switch view to plain text mode
but rectangle paint over viewport of scrollView
How i need to replace the standard border?
QFrame:ainter() ?
There is no such thing as "QFrame::Painter()".
where then to draw decoration of widget - border,shade ?
It's drawn in the paintEvent (probably using QStyle primitives). I don't think you really wish to change that, but of course it is possible by reimplementing the event and drawing your own frame. It might be simpler to use stylesheets to substitute the frame with your border image or changing the style to draw another frame.
Can I obtain painter for parent QFrame in paintEvent method in QListView and re-draw it the way I want? If I can, how can I get it? Or do I need to create my own QFrame based on standard and create my ListView based on QListView and QFrame (class myView(QWidget *parent = 0) : public QListView, public myFrame) ?
You don't "obtain" a painter, you create it:
Qt Code:
painter.drawRect(...); //... }To copy to clipboard, switch view to plain text mode
Bookmarks