Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTableWidget, CellWidget read only.



  • From google. I found that you can centralize a widget by making a Qwidget, Adding a layout and inserting the widget. This is cool and all but because it's not a QTableWidgetItem I don't know how to set flags and make it 'read only'

    Here's how I insert my widget in the table:

    buttonWidget = QWidget()
    bWidgetLayout = QHBoxLayout(buttonWidget)
    button = QPushButton()
    bWidgetLayout.addWidget(button)
    
    tableWidget.setCellWidget(0,0, buttonWidget)
    

  • Lifetime Qt Champion

    Hi,

    Call setEnabled(false).

    Beware of your use of cell widgets. It's not meant as a solution to populate full columns.


Log in to reply