PDA

View Full Version : How to set layout for QTreeView in QComboBox



kode
27th December 2010, 14:29
Hi all,

i have QComboBox with QTreeView in it. i set maxwidth = 20 for the combo and i want to make tree view wider(400). i try to make some layout and apply it to the combo, but i get errors.

How can i set the width of the tree view?

nroberts
27th December 2010, 20:08
Hi all,

i have QComboBox with QTreeView in it. i set maxwidth = 20 for the combo and i want to make tree view wider(400). i try to make some layout and apply it to the combo, but i get errors.

How can i set the width of the tree view?

This sounds to me like a very abnormal way to go about it. I assume what you're trying to do is get a tree view to show up when the user clicks the down arrow of a combo box. A better approach is probably to derive from the combo box (or use composition) and override the behavior of the down arrow (assuming this is possible) to pop up a window at the right location. That window can then be or contain a tree view/widget.

Maybe there's a way to do it exactly the way you are, but I have my doubts and it's probably not the way I would go about trying.

kode
28th December 2010, 08:46
Hi,

thanks for the reply. The desired result is to have a square combo box 20x20 px. On click the combo shows treeview widget ( because i want to show 4 columns ). The problem is mwhen i set the width of the combo treeview automaticaly shrink to 20px width and i want to make it wider.

I suppose i have to set some layout for treeview...

aamer4yu
28th December 2010, 11:55
Override the QComboBox::showPopup function. and show the view with desired geometry