QTableWidget's Header background color doesn't work in Win7



  • Hello, everyone,

    I've generated a duty roster using QTableWidget, having the horizontal headers the colleague's names and the vertical headers as a calendar, showing weekdays and holidays.

    I use the background colors of the QTableWidgetItem that goes as headerItem with the following code snippet:
    @ for(int i = 0; i < pDate.daysInMonth(); i++)
    {
    pDate.setDate(pDate.year(),pDate.month(),i+1);
    QTableWidgetItem* litem = new QTableWidgetItem();
    QString dt = QDate::shortDayName(pDate.dayOfWeek());
    dt.append("\n");
    dt.append(QString::number(i+1));
    litem->setText(dt);

        if(pDate.dayOfWeek() == 6)
        {
            litem->setBackground(QBrush(lSat));
            lwdays--;
        }
    
        if(pDate.dayOfWeek() == 7)
        {
            litem->setBackground(QBrush(lSun));
            lwdays--;
        }
    
        if(m_Holidays->checkForHoliday(pDate))
        {
            litem->setForeground(QBrush(lHolFg));
            litem->setBackground(QBrush(lHol));
            if(pDate.dayOfWeek()<6)
            {
                lwdays--;
            }
        }
    
        ui->tbwRoster->setHorizontalHeaderItem(i,litem);
        ui->tbwRoster->setColumnWidth(i,25);
    }@
    

    It works fine on Linux, but the background color does not change on Windows...

    Is it a bug, or am I doing wrong?

    Regards
    Joerg


  • Lifetime Qt Champion

    Hi,

    This rings a bell but I'm not sure. You should check the "bug report system":http://bugreports.qt-project.org to see if it's something known.



  • Hi,

    checked it, couldn't find anything.

    But here's some additional info:

    You get the same result when using colors with QPalette::Button for QPushButton and QComboBox.

    But when you change the Windows color scheme from "Win7", i.e. Aero, to "Classic", everything works fine, the colors are displayed correctly.

    The disadvantage is your desktop looks like Win95... do we want this...? :-)


  • Lifetime Qt Champion

    Surely not :)

    But this rings a bell, IIRC there was a bug related to the Aero theme but I can't remember exactly the thing



  • So, I'd say the bug is still unsolved... :(


  • Lifetime Qt Champion

    If you didn't find anything (maybe it was mentioned on the interest mailing list), then please open a new bug report providing a minimal compilable example that shows the problem


Log in to reply
 

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