Results 1 to 3 of 3

Thread: QTableWidget Background Color

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2008
    Location
    St. Louis, MO
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QTableWidget Background Color

    This code produces a table of toolbuttons (see attachment). How do I set the background color of the table to something other than its default white background?

    #include <QtGui>
    #include <QApplication>

    int main( int argc, char *argv[] )
    {
    QApplication app( argc, argv );

    QDialog *d = new QDialog;
    d->setWindowTitle( "Table Test" );

    QTableWidget *table = new QTableWidget( 2, 3 );
    QStringList headers = QStringList() << "A" << "B" << "C";
    table->setHorizontalHeaderLabels( headers );

    table->setGridStyle( Qt::NoPen );
    table->setCellWidget( 0, 0, new QToolButton );
    table->setCellWidget( 0, 1, new QToolButton );
    table->setCellWidget( 0, 2, new QToolButton );
    table->setCellWidget( 1, 0, new QToolButton );
    table->setCellWidget( 1, 1, new QToolButton );
    table->setCellWidget( 1, 2, new QToolButton );

    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget( table );

    d->setLayout( layout );
    d->show();

    return app.exec();
    }
    Attached Images Attached Images

Similar Threads

  1. Background Image in QTableWidget
    By mclark in forum Qt Programming
    Replies: 11
    Last Post: 6th June 2012, 17:06
  2. Change QPushButton Background Color, Qt4.3
    By Rayven in forum Qt Programming
    Replies: 5
    Last Post: 4th July 2009, 07:14
  3. how to change QTextEdit background color ?
    By mismael85 in forum Qt Programming
    Replies: 9
    Last Post: 26th June 2008, 22:05
  4. Menu bar background color focus
    By user_mail07 in forum Qt Tools
    Replies: 0
    Last Post: 18th May 2007, 01:25
  5. QLabel background color
    By munna in forum Newbie
    Replies: 3
    Last Post: 1st May 2006, 15:36

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.