Dejwi
Dejwi

Reputation: 4487

Qt Widget with tree organized items

I'd like to have an widget with items organized in tree structure. However it should be viewed in one line and every substree should be represented in braces. For example:

1. element1 2. element2 3. element3 (3. element31 4. element41 {4. element43 5. element53} 5. element 51 6. element61 3. element32 4. element 42) 4 element4 5. element5

Each element should also have an associated icon and should be clickable. I think about QListView or QTreeView. The second one sounds better but I have to idea how to force it to display items in such manner.

Upvotes: 1

Views: 366

Answers (1)

Lol4t0
Lol4t0

Reputation: 12547

The right way is still to implement your own view. As far as user interaction with view is rather limited, it should not be so difficult (see Qt's example of pieview, yours should be simpler).

Alternatively, you can just create an array of styled buttons (smth like this:)

//stylesheet:
QPushButton {
     background-color: white;
     border-width:0px;
    border-style:none;
 }
 QPushButton:pressed {
     background-color: blue;
     color:white;
 }
 QPushButton:checked {
     background-color: darkblue;
     color:white;
 }

Every button then will represent one item in your view.

Upvotes: 1

Related Questions