Results 1 to 12 of 12

Thread: Background Image in QTableWidget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Background Image in QTableWidget

    You should be able to query the style() for a default palette.

  2. The following user says thank you to wysota for this useful post:

    mclark (1st February 2008)

  3. #2
    Join Date
    Feb 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Exclamation Re: Background Image in QTableWidget

    Hi, sorry to bring this article up, but I really need some help.

    Here's my code:
    Qt Code:
    1. QPixmap pixmap("anime.jpg");
    2. QPalette palette = ui->tableWidget->palette();
    3. palette.setBrush(QPalette::Base, QBrush(pixmap));
    4. ui->tableWidget->setPalette(palette);
    5. ui->tableWidget->show();
    To copy to clipboard, switch view to plain text mode 

    What did I do wrong, that only the background behind cells gets colored?
    Cells are still white.

    I'm using designer.

    Here's image of the problem.
    problem.jpg

    Is there an easy way to make cells transparent or somehow use the image as background?
    Any help would be appreciated.

  4. #3
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Background Image in QTableWidget

    You're problem is different than the one I started this thread about. I had an empty table - no rows, no columns and wanted an image to display. You need transparent cells so the background image can show through.

    While I don't know how to do this, I would start by giving the cells no brush.
    Qt Code:
    1. QTableWidgetItem::setBackground( QBrush() );
    To copy to clipboard, switch view to plain text mode 
    If that didn't work I would look at setting the opacity of the brush (see QBrush documentation) or maybe this could be handled with a stylesheet.

    If you get nowhere with these suggestions, start a new thread. There are some very bright developers on this forum and someone must know the answer to this problem.

  5. #4
    Join Date
    Dec 2011
    Posts
    11
    Platforms
    Unix/X11

    Default Re: Background Image in QTableWidget

    I know this is an old thread but i have the same problem

    i have written this:
    Qt Code:
    1. QPalette palette = playlistTable.palette();
    2. QPixmap a = new QPixmap("/home/chris/playlist_background.png");
    3. QBrush brush = new QBrush(a);
    4. palette.setBrush(QPalette.ColorRole.Base, brush);
    5. playlistTable.setPalette(palette);
    To copy to clipboard, switch view to plain text mode 

    and it doesn't work

    PS: using QtJambi

Similar Threads

  1. Replies: 3
    Last Post: 18th May 2012, 10:12
  2. Replies: 15
    Last Post: 23rd March 2007, 16:16
  3. Setting background image of QFrame
    By Claymore in forum Qt Programming
    Replies: 2
    Last Post: 12th February 2007, 19:50
  4. background image in QTreeView
    By momesana in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2007, 06:25
  5. [QT4.1.1 XP] background image
    By incapacitant in forum Newbie
    Replies: 3
    Last Post: 1st March 2006, 13:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.