Then you are not telling us what you are really doing:
#include <QApplication>
#include <QTableWidget>
#include <QPushButton>
int main(int argc, char *argv[])
{
// Your code
btn1->setParent(tableStatus);
btn1
->setIconSize
((QSize(97,
25)));
btn1->setIcon(icon1);
btn1->setVisible(true);
tableStatus->setCellWidget(0,3,btn1);
// end of your code
tableStatus->show();
int ret = app.exec();
delete pixmap1;
delete tableStatus;
return ret;
}
#include <QApplication>
#include <QTableWidget>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTableWidget *tableStatus = new QTableWidget(4, 4);
// Your code
QPushButton *btn1 = new QPushButton();
btn1->setParent(tableStatus);
btn1->setIconSize((QSize(97,25)));
QPixmap* pixmap1 = new QPixmap("status.png");
QIcon icon1(*pixmap1);
btn1->setIcon(icon1);
btn1->setVisible(true);
tableStatus->setCellWidget(0,3,btn1);
// end of your code
tableStatus->show();
int ret = app.exec();
delete pixmap1;
delete tableStatus;
return ret;
}
To copy to clipboard, switch view to plain text mode
screen.png
Or, if you change line 19 to:
tableStatus->setCellWidget(0,5,btn1); // non-existent cell
tableStatus->setCellWidget(0,5,btn1); // non-existent cell
To copy to clipboard, switch view to plain text mode
screen.png
Bookmarks