Reputation: 83
The idea that I am looking to apply in my code is the create an "Add Tab" button in my tab bar. The likes of which can be seen in any browser like chrome. This requires that I must update the position of the button depending on what is the last tab in the tab bar.
To do so I am manually updating the position of the button using the setGeometry method of the QRect of the toolbutton. (example code snippet below)
self.tabButton.setGeometry( x+100, 0, self.tabButton.sizeHint().width(), self.tabButton.sizeHint().height())
which kind of works in terms of the horizontal placement of the button. However vertically it seems to be a little off
I have tried to adjust the vertical positioning of this Qtoolbutton manually as well like in the following snippet
self.tabButton.setGeometry( x+100, 10, self.tabButton.sizeHint().width(), self.tabButton.sizeHint().height())
This does position the add tab button better however a wierd this that happens when I do this is that the button becomes unresponsive. It took me quite a few tries to find out that this is somehow reducing the clickable area of the button. Which means that the button only works if if the user precisely clicks a very specific and small area towards the top of the button (this area is not the same as the previously shown position of the button). The only responsive part of the button in this version is the area marked red in the picture below.
Can someone please help me identify the possible issues in this case and/or if I am missing anything when setting the button geometries.
Upvotes: 0
Views: 126