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

Checkboxes in cells of QTableWidget are not coming correctly



  • I have following code

    QTableWidget* t = new QTableWidget;
    t->setRowCount(2)l

    QCheckBox* chkbox0 = new QCheckBox;
    QCheckBox* chkbox1 = new QCheckBox;

    int col =0;
    QWidget* wdg = new QWidget;
    QHBoxLayout* layout = new QHBoxLayout(wdg);
    layout->addWidget(chkbox0);
    wdg->setLayout(layout);
    t->setCellWidget(0, col, wdg);

    QWidget* wdg1 = new QWidget;
    QHBoxLayout* layout1 = new QHBoxLayout(wdg1);
    layout1->addWidget(chkbox1);
    wdg1->setLayout(layout);
    t->setCellWidget(1, col, wdg1);

    The checkboxes are not correctly properly the image is not coming proper
    the boundaries of checkboxes in the cell are not coming proper

    0_1546975423936_1.png

    I tried to increase the row height setRowHeight , it did not work out .

    Any suggestions would help


  • Lifetime Qt Champion

    Hi
    layout ->setContentsMargins(0,0,0,0);
    is the cure.
    The default margins cuts the checkbox.


Log in to reply