2021_11_26小结


1. tableView表头设置边框

ui->tableView->setStyleSheet("QHeaderView::section, QTableCornerButton::section {padding: 1px;border: none;border-bottom: 1px solid rgb(75, 120, 154);border-right: 1px solid rgb(75, 120, 154);border-bottom: 1px solid gray;}");

2. 关于设置代理之后对应控件一直浮动在表格左上角解决方案

void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;

重写updateEditorGeometry函数

 

解决方案

文档说明解释说明

2.1.1. geometry : moveEvent()) and/or a resize event (resizeEvent()) immediately. If the widget is not currently visible, it is guaranteed to receive appropriate events before it is shown.
  • The size component is adjusted if it lies outside the range defined byminimumSize() and maximumSize().
  • Warning: Calling setGeometry() inside resizeEvent() or moveEvent() can lead to infinite recursion.
  • See the Window Geometry documentation for an overview of geometry issues with windows.
  • By default, this property contains a value that depends on the user's platform and screen geometry.
  • 硬核翻译:

    • 此属性保存小部件相对于其父级的几何图形,不包括窗口框架。
    • 当更改几何图形时,小部件(如果可见)会立即接收移动事件(moveEvent())和/或调整大小事件(resizeEvent())。如果小部件当前不可见,则保证在显示之前接收适当的事件。
    • 如果大小组件位于由minimumSize()和maximumSize()定义的范围之外,则会对其进行调整。
    • 警告:在resizeEvent()或moveEvent()内调用setGeometry()可能导致无限递归。
    • 有关windows几何图形问题的概述,请参见windows几何图形文档。
    • 默认情况下,此属性包含一个值,该值取决于用户的平台和屏幕几何图形。