[PyQt] Parent/Child widget clipping

James Polk jpolk5001 at yahoo.com
Mon Jan 30 23:07:24 GMT 2012



Greetings All,

Doing some prototyping where I have a simple QTreeWidget with 3 items.
Each item has 3 simple children.

Using QTreeWidget.setItemWidget()....I "set/insert" a simple QTableWidget into
a child of one of the tree's parent items (first column)


The problem is that the "child-table" width is wider than the "parent-tree"'s first column,
so that parent-tree->column2 clips the child-table.

This phenomena is pretty much identical to this example on stackoverflow  (last pix)


http://stackoverflow.com/questions/6133367/qtreewidget-with-multiple-columns-limits-number-of-child-items

However, in that example, the problem is "solved" by manually (or could be automatic) resizing of
the parent columns by simply pulling it wider,etc..

But in my prototype, I need the entire "child-table" to display in it's entirety but I need the columns
of the "parent-tree" to remain the same width.

In other words, I need to override the default behaviour of having the tree define the child's display region.

I've tried several things...all to no avail...

I chose to use Tree/Table-Widgets this time, instead of Tree/Table-Views....would the "views" method
perhaps solve this dilemma?

If there's no way to solve this directly....any thoughts about "constraining" the position of a widget to
another widget?...bypassing the parent/child relationship in favor of functionality that would "snap"
a table widget's position to a marker, or anchor on the tree widget?  Sounds crude, I know...but
trying to figure out any workaround...

Would doing something like "setItemLayout" (instead of setItemWidget) yield a layout that would
paint over it's parent?....(albeit I can't seem to find a function like "setItemLayout", lol)

Any and all suggestions or solutions or workarounds are greatly appreciated..
Cheers,
Jim

(Simple example attached)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120130/3bd239e7/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example2.py
Type: application/octet-stream
Size: 1496 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120130/3bd239e7/attachment.obj>


More information about the PyQt mailing list