手动将Qtoolbutton的几何形状与可点击区域的几何弄乱
我想在代码中应用的想法是我的标签栏中创建一个“添加选项卡”按钮。像Chrome这样的浏览器中都可以看到其中的类似。这要求我必须根据标签栏中的最后一个选项卡更新按钮的位置。
这样做,因此我正在使用工具按钮的QRECT的设定测定法手动更新按钮的位置。 (下面的示例代码段)
self.tabButton.setGeometry( x+100, 0, self.tabButton.sizeHint().width(), self.tabButton.sizeHint().height())
在按钮的水平放置方面有效。但是垂直方面似乎有点
我试图在以下片段中手动调整此qtoolbutton的垂直定位
self.tabButton.setGeometry( x+100, 10, self.tabButton.sizeHint().width(), self.tabButton.sizeHint().height())
dvzoi.png“ alt =”“添加”选项卡 当我这样做时,发生这种情况是因为该按钮变得无反应。我花了很多时间尝试发现这在某种程度上减少了按钮的可点击区域。这意味着只有当用户精确单击按钮顶部的非常特定且小的区域时(该区域与按钮的先前显示的位置不同)时,该按钮才起作用。此版本中按钮的唯一响应部分是下图中标记为红色的区域。
有人可以帮助我确定这种情况下可能的问题和/或如果我在设置按钮几何时缺少任何内容。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论