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();
}
Bookmarks