how to get one common cell in QTableWidget
-
This post is deleted!
-
Why do you duplicate posts https://forum.qt.io/topic/97391/how-to-design-the-form-need-valuable-inputs ?
-
I delete here and post in the orginal . . Could you please answer my question
-
I have written a code
#include "mainwindow.h"
#include <QTableWidget>MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
QTableWidget * t = new QTableWidget;
t->setColumnCount(5);
t->setRowCount(2);
QStringList headerLabels;QString col1 = "Col1"; QString col2 = "Col2"; QString col3 = "Col3"; QString col4 = "Col4"; QString col5 = "Col5"; headerLabels << col1 << col2 << col3 << col4 << col5; t->setHorizontalHeaderLabels(headerLabels); t->show();
}
I am getting following table
I do not want the cell in red and in fact I need 1 in place of red cell any idea
-
@Qt-Enthusiast
Hi
You can look on how to style the red part
http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtableview
(QTableView QTableCornerButton::section)I dont get this part
- and in fact I need 1 in place of red cell
Can you explain better ?
you mean dont have any headerLabels so
first row start there ? -
yes
The row should start from red cell and Also I want the form as -
@Qt-Enthusiast
hi
you can hide the header with
ui->tableWidget->verticalHeader()->setVisible(false); -
What I have understood now is that you don't want vertical headers. Can you just try the following in your constructor ?
t->verticalHeader()->hide();
-
HOW TO INSERT Label + button at the last cells of last co![0_1544280441906_
-
-
In this case I have a Label + button . I can I get both . Do I have to put a custom class
-
@Qt-Enthusiast said in how to get one common cell in QTabelWidget:
In this case I have a Label + button . I can I get both . Do I have to put a custom class
Either that (a QHBoxLayout for example) or just put them in two columns
-
@Qt-Enthusiast said in how to get one common cell in QTableWidget:
#include "mainwindow.h"
#include <QTableWidget>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
QTableWidget * t = new QTableWidget;
t->setColumnCount(5);
t->setRowCount(2);
QStringList headerLabels;
QString col1 = "Col1";
QString col2 = "Col2";QString col3 = "Col3";
QString col4 = "Col4";
QString col5 = "Col5";
headerLabels << col1 << col2 << col3 << col4 << col5;
t->setHorizontalHeaderLabels(headerLabels);
t->show();}
getting compilation error her
#include "mainwindow.h"
#include <QTableWidget>
#include <QPushButton>
#include <QComboBox>
#include <QLineEdit>
#include <QHBoxLayout>
#include <QLabel>
#include <QHBoxLayout>MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
QTableWidget * t = new QTableWidget;
t->setColumnCount(5);
t->setRowCount(3);
QStringList headerLabels;QString col1 = "Col1";
QString col2 = "Col2";QString col3 = "Col3";
QString col4 = "Col4";
QString col5 = "Col5";
headerLabels << col1 << col2 << col3 << col4 << col5;
t->setHorizontalHeaderLabels(headerLabels);
QPushButton* button = new QPushButton();
button->setText("No of Mappings");QPushButton* button1 = new QPushButton();
button1->setText("Group");QPushButton* button2 = new QPushButton();
button2->setText("Type");QPushButton* button3 = new QPushButton();
button3->setText("Rules");QPushButton* button4 = new QPushButton();
button4->setText("Options");t->setCellWidget(0,0,button);
t->setCellWidget(0,1,button1);
t->setCellWidget(0,2,button2);
t->setCellWidget(0,3,button3);
t->setCellWidget(0,4,button4);t->setCellWidget(1,2,new QComboBox());
t->setCellWidget(2,2,new QComboBox());
t->setCellWidget(1,3,new QLineEdit());
t->setCellWidget(2,3,new QLineEdit());
QHBoxLayout* hbox = new QHBoxLayout ;QLabel* label = new QLabel("Options");
QPushButton * button22;
button2->setText("+");
hbox->addWidget(label);
hbox->addWidget(button22);
t->setCellWidget(1,4,hbox);QHBoxLayout* hbox1 = new QHBoxLayout ;
QPushButton * button31 = new QPushButton;
button31->setText("+");
hbox1->addWidget(label);
hbox1->addWidget(button3);
t->setCellWidget(1,4,hbox1);t->show();
}
MainWindow::~MainWindow()
{}
-
@Qt-Enthusiast said in how to get one common cell in QTableWidget:
getting compilation error her
Don't you think you should post the error?
-
The ideal solution is using a custom
QStyledItemDelegate
. If you can't be asked/want to delay the painful process you can design your label+button as a widget in designer and then use this delegate