Fill QTableWidget and refresh it with button
Hi all!
Guys please help me. I have QTableWidget in Dialog Window
Code:
AddAgentDlg
::AddAgentDlg(QWidget *parent
){
ui.setupUi(this);
connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(pressedB()));
connect(ui.pushButton_3, SIGNAL(clicked()), this, SLOT(addtextureclicked()));
connect(ui.comboBox, SIGNAL(activated(const QString&)), this, SLOT(opendialog(const QString&)));
connect(ui.tableWidget, SIGNAL(cellDoubleClicked(0,0)), this, SLOT(addtextureclicked()));
connect(this, SIGNAL(update1()), this, SLOT(update2()));
attr = ".3ds";
QFileInfoList dirContent
= dir.
entryInfoList(QStringList()<<
"*.Png",
QDir::Files |
QDir::NoDotAndDotDot);
ui.tableWidget->setColumnCount(5);
ui.tableWidget->setRowCount(dirContent.size());
ui.tableWidget->resizeRowsToContents();
ui.tableWidget->resizeColumnsToContents();
addItem
->setData
(Qt
::DecorationRole,
QPixmap("media/addItem.png").
scaled(60,
60));
addItem
->setData
(Qt
::ToolTipRole,
QVariant("Add Texture Image"));
ui.tableWidget->setItem(0,0, addItem);
{
static int row = 0, column = 1, columnNumber = 5;
img
->setData
(Qt
::DecorationRole,
QPixmap(fileInfo.
absoluteFilePath()).
scaled(60,
60));
QString str_temp
= fileInfo.
absoluteFilePath();
img->setData(Qt::UserRole+1, str2 );
ui.tableWidget->setItem(row,column++,img);
if (column > columnNumber) {
column = 0;
row++;
}
}
}
Is it right? How can I make it update via pushButton? ui.tableWidget->update() nor repaint doesn't work.
Re: Fill QTableWidget and refresh it with button
Where to you update the content?
And check the output log of your application, it will tell you that your fourth connect is not possible.
Cheers,
_
2 Attachment(s)
Re: Fill QTableWidget and refresh it with button
I have push button that connect with this slot
Code:
ui.tableWidget->clear();
ui.tableWidget->setRowCount(0);
ui.tableWidget->setColumnCount(0);
filltable();
Where filltable is function to populate QTableWidget. First populate in window is perfect. But when I push button, clear data and try repopulate table this is what i get : First populate - ok Attachment 10825 after press pushButton Attachment 10826 it's shift images. i don't understand why
Re: Fill QTableWidget and refresh it with button
So both times you call filltable()?
The code you posted so far has nothing to do with filltable()
How do you expect help if your program is doing something totally different than what you post?
Cheers,
_