I wrote somes , hope it's your answer what u want
and it works good , I'll add them end of the reply
But the place I don't understand is how u can see a cople of checkboxes and radiobuttons to create a project which is base class is QMainWindow in the wizard
pls can u take screen shots or take a video
.pro file
#-------------------------------------------------
#
# Project created by QtCreator 2013-09-10T20:45:39
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = deneme
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
#-------------------------------------------------
#
# Project created by QtCreator 2013-09-10T20:45:39
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = deneme
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
To copy to clipboard, switch view to plain text mode
.h file
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QTableWidgetItem>
namespace Ui {
class MainWindow;
}
{
Q_OBJECT
public:
explicit MainWindow
(QWidget *parent
= 0);
~MainWindow();
private:
Ui::MainWindow *ui;
private slots:
void addColumn();
};
#endif // MAINWINDOW_H
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QTableWidgetItem>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
private slots:
void addColumn();
};
#endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->chkBox_add,SIGNAL(clicked()),this,SLOT(addColumn()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::addColumn()
{
int column;
column = ui->tableWidget->columnCount(); // now column = 0 because there isn't any columns
ui->tableWidget->setColumnCount(column+1); // addin new column
if(ui->lnEdt_AdColumnName->text().isEmpty() == false)
ui->tableWidget->setHorizontalHeaderItem(column, item);
else {
item->setText(ui->tableWidget->horizontalHeaderItem(column-1)->text());
ui->tableWidget->setHorizontalHeaderItem(column, item); // the column array starts from 0
}
ui->chkBox_add->setChecked(false);
ui->lnEdt_AdColumnName->setText("");
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->chkBox_add,SIGNAL(clicked()),this,SLOT(addColumn()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::addColumn()
{
int column;
column = ui->tableWidget->columnCount(); // now column = 0 because there isn't any columns
QTableWidgetItem *item = new QTableWidgetItem(QString(ui->lnEdt_AdColumnName->text()),QTableWidgetItem::Type);
ui->tableWidget->setColumnCount(column+1); // addin new column
if(ui->lnEdt_AdColumnName->text().isEmpty() == false)
ui->tableWidget->setHorizontalHeaderItem(column, item);
else {
item->setText(ui->tableWidget->horizontalHeaderItem(column-1)->text());
ui->tableWidget->setHorizontalHeaderItem(column, item); // the column array starts from 0
}
ui->chkBox_add->setChecked(false);
ui->lnEdt_AdColumnName->setText("");
}
To copy to clipboard, switch view to plain text mode
.ui file edit mode
<?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>566</width>
<height>350</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QTableWidget" name="tableWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>551</width>
<height>271</height>
</rect>
</property>
</widget>
<widget class="QCheckBox" name="chkBox_add">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>141</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>add column</string>
</property>
</widget>
<widget class="QLineEdit" name="lnEdt_AdColumnName">
<property name="geometry">
<rect>
<x>130</x>
<y>10</y>
<width>113</width>
<height>20</height>
</rect>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>566</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>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</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>566</width>
<height>350</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QTableWidget" name="tableWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>551</width>
<height>271</height>
</rect>
</property>
</widget>
<widget class="QCheckBox" name="chkBox_add">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>141</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>add column</string>
</property>
</widget>
<widget class="QLineEdit" name="lnEdt_AdColumnName">
<property name="geometry">
<rect>
<x>130</x>
<y>10</y>
<width>113</width>
<height>20</height>
</rect>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>566</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>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
To copy to clipboard, switch view to plain text mode
.ui file design mode
Attachment 9570
I wrote all of them because of I don't understand your checkbox and radiobutton event exactly
Bookmarks