dagvegar
29th October 2012, 08:06
Hi folks,
I have uploaded a minimal example (TreeItemTest.zip) to point at my specific issue.
The example program has two items, where one is child of the other. A QPushButton is shown on every QTreeWidgetItem. In addition, when having children, a QPushButton for expanding the tree is shown at the right.
The two items are shown running the same code (using delegate), but they look different because the expand button is hidden when not having children.
When clicking the "Left" button, it turns red (just to illustrate that its hit). To check if it is hit, the mouse click is calculated to check if the cursor is at the target.
And here is the problem, try clicking the "Left" buttons, on the one above at the left side of the "Left" button and then click at the below button at the right side of it. (Thus when clicking the buttons, the clicks are not aligned vertically.) As seen, you will sometimes not get a hit (the button does not change color).
It seems like the geometry of the button clicked is the geometry of the other button (and visa versa).
The calculation of the button positions is done in the editorEvent. I have also tried to put this code in the mousePressEvent at the QTreeWidget level without success.
Could anyone point at what is wrong and show a way to do this correctly. A link to the exact same issue would do, thus I haven't found one yet.
Big thanks!
I have uploaded a minimal example (TreeItemTest.zip) to point at my specific issue.
The example program has two items, where one is child of the other. A QPushButton is shown on every QTreeWidgetItem. In addition, when having children, a QPushButton for expanding the tree is shown at the right.
The two items are shown running the same code (using delegate), but they look different because the expand button is hidden when not having children.
When clicking the "Left" button, it turns red (just to illustrate that its hit). To check if it is hit, the mouse click is calculated to check if the cursor is at the target.
And here is the problem, try clicking the "Left" buttons, on the one above at the left side of the "Left" button and then click at the below button at the right side of it. (Thus when clicking the buttons, the clicks are not aligned vertically.) As seen, you will sometimes not get a hit (the button does not change color).
It seems like the geometry of the button clicked is the geometry of the other button (and visa versa).
The calculation of the button positions is done in the editorEvent. I have also tried to put this code in the mousePressEvent at the QTreeWidget level without success.
Could anyone point at what is wrong and show a way to do this correctly. A link to the exact same issue would do, thus I haven't found one yet.
Big thanks!