Is there a way to align or manipulate the position of a QIcon inside a QTableWidgetItem?

夙愿已清 提交于 2020-01-17 04:24:06

问题


Intro: I am using PySide and the Qt Framework to build a GUI app

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.

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.

thanks


回答1:


I would probably end up using QTableWidget::setCellWidget()

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.



来源:https://stackoverflow.com/questions/11463016/is-there-a-way-to-align-or-manipulate-the-position-of-a-qicon-inside-a-qtablewid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!