How to set backround image for QTableWidget?



  • Hi,

    Can Anybody help me to set the background image for QTableWidget.
    I had tried with following code but its not working....

    QPalette palette = ui->tableWidget->palette();
    QPixmap jpgImage( "/home/rcdtcpu26/Desktop/aero1.jpg");
    palette.setBrush(QPalette::Base, QBrush(jpgImage));
    

    Thank you.
    ui->tableWidget->setPalette(palette);



  • Hi you can try this

    QPalette* palette = new QPalette();	
     palette->setBrush(QPalette::Base,*(QBrush(*(QPixmap("aero1.jpg")))));
     table->setPalette(*palette); 
    

  • Lifetime Qt Champion

    @Ratzz Why all these heap allocated objects ?

    QPalette tablePalette = table->palette();
    palette.setBrush(QPaletter::Base, QPixmap("aero1"));
    table->setPalette(tablePalette);
    

    is enough and cleaner.


Log in to reply
 

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