You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, September 8th 2010, 10:18pm

Custom item painting in view widget?

Let's say I have a custom widget that handles editing great for an item in a view, maybe a QTreeView (doesn't really matter). I have an item delegate that I can use to intercept the paint call for the item. Is it possible to render the custom widget without creating it or trying to figure out the paint calls to make manually? Can I use the style to render these in some logical way?

Any suggestions are greatly appreciated.

2

Thursday, September 9th 2010, 12:20am

IMHO you can only render passive widgets this way (QProgressBar, non pushable QPushButton,...), or you would have to rewrite all the mouse/keyboard interaction from the events received by the QTableWidget itself.

3

Thursday, September 9th 2010, 2:04pm

Ok, assuming passive is fine how would you do it? Say I just want to draw it but I don't want to keep it in memory for every single item (because it could be a lot). Is there a way to just render it?

4

Thursday, September 9th 2010, 3:03pm

There is an example in the documentation that should work for simple widgets:
http://doc.qt.nokia.com/latest/network-t…window-cpp.html

And for your own widgets, you can try using QWidget::render in the delegate paint method.

5

Thursday, September 9th 2010, 3:12pm

Thanks. I'm fine with simple widgets that styles already render. I was more thinking about custom widgets that styles don't already do.

I'm guessing there's really no way to do what I want to do. As an example, say I have something like a custom widget that contains maybe three sub-widgets - maybe an edit box, and two widgets that do custom rendering - and renders them all together, maybe even using a layout object to organize them. The custom widget doesn't actually do any rendering, it just contains them and passes the rendering off to the children. It seems that my only option is to somehow reproduce all of the rendering in the delegate's paint method. This is to be a pain that could have been avoided since I already have classes that should be able to do all of the rendering and layout work.

This post has been edited 1 times, last edit by "bpoteat" (Sep 9th 2010, 3:20pm)