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:

    !http://sdz-upload.s3.amazonaws.com/prod/upload/qscrollarea.png(http://sdz-upload.s3.amazonaws.com/prod/upload/qscrollarea.png)!

    Background color with a normal tab:

    !http://sdz-upload.s3.amazonaws.com/prod/upload/normal1.png(http://sdz-upload.s3.amazonaws.com/prod/upload/normal1.png)!

    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":http://qt-project.org/doc/qt-4.8/qtglobal.html#Q_OS_LINUX:
    @
    #ifdef Q_OS_LINUX
    scrollview->setStyleSheet(...);
    #endif
    @



  • 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.