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++;
}
}
}
AddAgentDlg::AddAgentDlg(QWidget *parent)
: QDialog(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";
QDir dir("textures/");
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();
QTableWidgetItem* addItem = new QTableWidgetItem;
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);
Q_FOREACH (QFileInfo fileInfo, dirContent)
{
static int row = 0, column = 1, columnNumber = 5;
QTableWidgetItem* img = new QTableWidgetItem;
img->setData(Qt::DecorationRole, QPixmap(fileInfo.absoluteFilePath()).scaled(60,60));
QString str_temp = fileInfo.absoluteFilePath();
QString str = fileInfo.fileName();
QVariant str2(str);
img->setData(Qt::UserRole+1, str2 );
ui.tableWidget->setItem(row,column++,img);
if (column > columnNumber) {
column = 0;
row++;
}
}
}
To copy to clipboard, switch view to plain text mode
Is it right? How can I make it update via pushButton? ui.tableWidget->update() nor repaint doesn't work.
Bookmarks