How to change the size of icons in QTableWidgetItem or in QTableWidget



  • I want to create QTableWidget,Each row including pictures and text, and I want to make pictures and text images are the same size,the text can changed size ,but i do not know how to change the size of icon ,Who can solve my problem yet ,Thanks!


  • Qt Champions 2017

    @Bidjc
    HI and welcome
    please see
    http://doc.qt.io/qt-5/qabstractitemview.html#iconSize-prop
    so something like

    QTableWidget *table = new QTableWidget(this);
    table->setIconSize(QSize(100, 100));
    QTableWidgetItem *item = new QTableWidgetItem;
    item->setSizeHint(QSize(100, 100));
    item->setIcon(QIcon(fileName));
    table->setItem(0, 0, item);
    

    [edit: updated documentation link for latest version SGaist]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.