Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to set backround image for QTableWidget?

How to set backround image for QTableWidget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vIJI
    wrote on last edited by
    #1

    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);

    1 Reply Last reply
    0
    • RatzzR Offline
      RatzzR Offline
      Ratzz
      wrote on last edited by Ratzz
      #2

      Hi you can try this

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

      --Alles ist gut.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Ratzz Why all these heap allocated objects ?

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

        is enough and cleaner.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved