How to add data into the QTableWidget
Hi All,
I have a QTableWidget which has 200 rows and 4 columns. The user will input the data from 4 QlineEdits in a different dialog. These 4 QlineEdit Values has to be displayed in the QTableWidget. How to resolve this issue. any snippts will be greatful.
Re: How to add data into the QTableWidget
the simplest way. it is to pass pointer to QTableWidget into your dialog.
Code:
: Dialog(parent), m_table(table)
{
....
}
void Dialog::saveDataIntoTable()
{
if (!m_table)
return;
const int currentRow = m_table->rowCount();
m_table->setRowCount(currentRow + 1);
...
}
Re: How to add data into the QTableWidget
another way is to create getters in your dialog and use them to get values after dialog.exec() returns.
Re: How to add data into the QTableWidget
Thanks for the reply my intension is to make application similar to addressbook example in Qt but instead of Listview i need to use TableWidget..
And here is my code snippet
Code:
ToolForm
::ToolForm( QDialog *parent, Qt
::WindowFlags f
){
setupViews();
setupUi(this);
}
ToolForm::~ToolForm()
{
}
void ToolForm::setupViews()
{
tooltableWidget
->setHorizontalHeaderLabels
(QStringList() << tr
("TOOL NUMBER") << tr("DIAMETER")
<< tr("LENGTH")
<< tr("UNITS"));
tooltableWidget->verticalHeader()->setVisible(false);
tooltableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
tooltableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
tooltableWidget->setShowGrid(false);
tooltableWidget
->setGeometry
(QRect(0,
100,
781,
281));
tooltableWidget->horizontalHeader()->resizeSection(1, 250);
tooltableWidget->horizontalHeader()->resizeSection(2, 250);
tooltableWidget->horizontalHeader()->resizeSection(3, 180);
}
void ToolForm::add_tool()
{
ToolAddDialog tooladddialog;
if( tooladddialog.exec())
{
QString str
= tooladddialog.
toolgetValues();
//now i need to display the values from tooladddialog. to TableWidget
}
}
how to proceed with this..
Re: How to add data into the QTableWidget
Hi All,
I tried with the method which was replied by spirit but its not working can anyone tell me how to resolve this issue.
Re: How to add data into the QTableWidget
Quote:
Originally Posted by
grsandeep85
I tried with the method which was replied by spirit but its not working can anyone tell me how to resolve this issue.
Then you probably have an error in your source code. Show us your relevant code, then we can help.
Re: How to add data into the QTableWidget
Could some one tell me how to do the same using JavaScript? Really appreciated.