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


    @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();
    projectConfigurationTabWidget->addTab(editCompilerConfigurationScrollArea, QObject::tr("Compiler"));
    projectConfigurationTabWidget->addTab(editDirectoriesConfigurationWidget(), QObject::tr("Directories"));
    QHBoxLayout* buttonsLayout = new QHBoxLayout();
    QPushButton* okButton = new QPushButton(QObject::tr("Ok"));
    QObject::connect(okButton, SIGNAL(clicked()), this, SLOT(saveChanges()));
    QPushButton* cancelButton = new QPushButton(QObject::tr("Cancel"));
    QObject::connect(cancelButton, SIGNAL(clicked()), this, SLOT(close()));


    QWidget* EditProjectSettingsDialog::editCompilerConfigurationWidget()
    // Random stuff here
    QFormLayout* editCMakeConfigurationLayout = new QFormLayout();

    QComboBox* availablesCompilersComboBox = new QComboBox();
    for (const QString& compilerName : availablesCompilers())
    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();
    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 ;)

  • Moderators

    the tabs itself actually have the same background color. The scroll view has the grey background.
    You could use stylesheets to avoid the problem.

  • Thanks raven-worx ;) I know understand the problem. But the thing is, if I manually modified the background color, I'll have to handle all the operating system the program could run on, don't I. Is there any os-agnostic way to proceed ?

  • Moderators

    only if you use the "platform macros":
    #ifdef Q_OS_LINUX

  • Ok thanks. I tought Qt would do it for me ;(
    I'll try to work it out.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.