SOLVED: Set Tab Icon with code
- 
Hello Developers, I have been trying to set an icon for a tab in a tabWidget using code but failed so far. Its easier with the form designer but I need to use code to make my app dynamic. 
 Here's the code for mainwindow.cpp, the rest of the files are the default for a MainWindow project.
 Please show me how to set icons with size 20x20p for both tab1 and tab2 below.mainwindow.cpp 
 @#include "mainwindow.h"
 #include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) : 
 QMainWindow(parent),
 ui(new Ui::MainWindow)
 {
 ui->setupUi(this);QTabWidget *tabWidget = new QTabWidget; QWidget *tab1 = new QWidget; QWidget *tab2 = new QWidget; setCentralWidget(tabWidget); tabWidget->insertTab(0, tab1, "Tab 1"); tabWidget->insertTab(1, tab2, "Tab 2");} MainWindow::~MainWindow() 
 {
 delete ui;
 }@Thanks in advance 
- 
Hi Qkato. 
 Did you try insert tabs with this option?@int QTabWidget::insertTab(int index, QWidget * page, const QIcon & icon, const QString & label)@ Hope it's util. 
 Regards.
- 
Read the manual please: @ 
 int QTabWidget::insertTab(int index, QWidget * page, const QIcon & icon, const QString & label)
 @
- 
or even QTabWidget::setTabIcon() ... 
- 
@QIcon(“:/image/icon.png”)@ 
