问题描述
简介:我正在使用 PySide 和 Qt 框架来构建一个 GUI 应用程序
Intro: I am using PySide and the Qt Framework to build a GUI app
我在 QTableWidgetItem 中动态添加 edit
和 delete
图标,我试图将它们对齐在单元格的中心.我已经在 QTableWidget 的各个部分尝试过 setTextAlign 和 setStyleSheet.
I am dynamically adding edit
and delete
icons in a QTableWidgetItem and I am trying to align them in the center of the cell. I have tried setTextAlign and setStyleSheet on various parts of the QTableWidget.
如果有人知道一个很棒的解决方法.
If anyone knows a workaround that would be awesome.
我还希望这些是可点击的,这样如果用户点击edit
,他们将能够编辑该行适用的相应对象.如果有人也能帮我解决这个问题,那就更棒了.
I am also wanting these to be clickable so that if the user clicks the edit
they will be able to edit the corresponding object that row applies to. If someone could help me out with this as well that would be even more awesome.
谢谢
推荐答案
我可能最终会使用 QTableWidget::setCellWidget()
您可以创建自己的自定义小部件,在这种情况下,您可以尝试在设计器中创建一个以 QFrame
为中心的 QToolButton
,然后将其设置为您希望它出现在表格中的单元格的小部件.
You'd be able to create your own custom widget, in this case you might try creating a QToolButton
centered inside of a QFrame
in designer and then set that as the widget for the cells in your table that you want it to appear in.
这篇关于有没有办法在 QTableWidgetItem 中对齐或操纵 QIcon 的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!