Weird background color with a QScrollArea under KDE 4.10
-
Hi everybody,
I'm currently working on a project and I'd like to display a list of items, list with an unknown length at compile time. So I'm trying to use a QScrollArea to display list of any length without modifying the dimension of my window. It compiles but the aspect of my window is a bit weird imho.
I'll let you judge
Code:
@EditProjectSettingsDialog::EditProjectSettingsDialog(QWidget* parent) : QDialog(parent)
{
setWindowTitle(QObject::tr("Edit project settings"));
resize(640, 380);_changesWereMade = false; QVBoxLayout* mainLayout = new QVBoxLayout(); QTabWidget* projectConfigurationTabWidget = new QTabWidget(); QScrollArea* editCompilerConfigurationScrollArea = new QScrollArea(); editCompilerConfigurationScrollArea->setWidget(editCompilerConfigurationWidget()); projectConfigurationTabWidget->addTab(editCompilerConfigurationScrollArea, QObject::tr("Compiler")); projectConfigurationTabWidget->addTab(editDirectoriesConfigurationWidget(), QObject::tr("Directories")); mainLayout->addWidget(projectConfigurationTabWidget); QHBoxLayout* buttonsLayout = new QHBoxLayout(); QPushButton* okButton = new QPushButton(QObject::tr("Ok")); QObject::connect(okButton, SIGNAL(clicked()), this, SLOT(saveChanges())); buttonsLayout->addWidget(okButton); QPushButton* cancelButton = new QPushButton(QObject::tr("Cancel")); QObject::connect(cancelButton, SIGNAL(clicked()), this, SLOT(close())); buttonsLayout->addWidget(cancelButton); mainLayout->addLayout(buttonsLayout); setLayout(mainLayout);
}
QWidget* EditProjectSettingsDialog::editCompilerConfigurationWidget()
{
// Random stuff here
QFormLayout* editCMakeConfigurationLayout = new QFormLayout();QComboBox* availablesCompilersComboBox = new QComboBox(); for (const QString& compilerName : availablesCompilers()) availablesCompilersComboBox->addItem(compilerName); editCMakeConfigurationLayout->addRow("Compiler: ", availablesCompilersComboBox); editCMakeConfigurationLayout->addRow("Procude debugging symbols [-g]", new QCheckBox()); editCMakeConfigurationLayout->addRow("Have g++ follow the new C++ standard [-std=c++11]", new QCheckBox()); editCMakeConfigurationLayout->addRow("Inhibit all warning messages [-w]", new QCheckBox()); editCMakeConfigurationLayout->addRow("Warn if main is not conformant [-Wmain]", new QCheckBox()); // Some code concerning editCMakeConfigurationLayout QWidget* editCMakeConfigurationWidget = new QWidget(); editCMakeConfigurationWidget->setLayout(editCMakeConfigurationLayout); return editCMakeConfigurationWidget;
}@
Aspect of my window:
Background color with a normal tab:
As you can see, the two tabs doesn't have the same background color and that's annoying me.
Does anybody knows why it's so ? Thanks in advance ;)
-
the tabs itself actually have the same background color. The scroll view has the grey background.
You could use stylesheets to avoid the problem. -
only if you use the "platform macros":http://qt-project.org/doc/qt-4.8/qtglobal.html#Q_OS_LINUX:
@
#ifdef Q_OS_LINUX
scrollview->setStyleSheet(...);
#endif
@