Лучший ответ это пример.
Создаём приложение QtWidgets.
Накидываем в .ui для удобства сократил до кнопки и одного qTableWidget-а.

Прописываем в коде динамический элемент.
Для начала объявляем в заголовочном файле в основном классе QCheckBox (.h).
После вызываем его в реализации, при нажатии кнопок (.срр).
--- Вот код ----
.pro
#-------------------------------------------------
#
# Project created by QtCreator 2018-06-13T14:38:41
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test11
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
mainwindows.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtWidgets>
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_pushButton_clicked();
private:
Ui::MainWindow *ui;
// Создаём виджет, который будет содержать в себе чекбокс
QWidget *checkBoxWidget = new QWidget();
QCheckBox *checkBox = new QCheckBox(); // объявляем и инициализируем чекбокс
QHBoxLayout *layoutCheckBox = new QHBoxLayout(checkBoxWidget); // создаём слой с привязкой к виджету
};
#endif // MAINWINDOW_H
main.cpp
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
mainwindows.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
//-- добавляем чек бокс в таблицу
checkBoxWidget = new QWidget(); // создаём новый qwidget()
checkBox = new QCheckBox(); // объявляем и инициализируем чекбокс
layoutCheckBox = new QHBoxLayout(checkBoxWidget); // создаём слой с привязкой к виджету
checkBox->setText(QString::number(666));
layoutCheckBox->addWidget(checkBox); // Устанавливаем чекбокс в слой
// checkBox->set
layoutCheckBox->setAlignment(Qt::AlignCenter); // Отцентровываем чекбокс
layoutCheckBox->setContentsMargins(0,0,0,0); // Устанавливаем нулевые отступы
ui->tW_test->insertRow(ui->tW_test->rowCount());//вводим колич строк (возвращ колич строк)
ui->tW_test->setCellWidget(ui->tW_test->rowCount()-1, 1, checkBoxWidget); // добавляем элемент в таблицу (строка, столбец, добавляемый элемент)
}
mainwindows.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>727</width>
<height>450</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTableWidget" name="tW_test">
<property name="rowCount">
<number>0</number>
</property>
<property name="columnCount">
<number>3</number>
</property>
<column/>
<column/>
<column/>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>727</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
И вот результат.
