[Python] QTableWidget cells background color has unwanted "rounded padding"

Discussão em 'Python' iniciado por Stack, Maio 26, 2025.

  1. Stack

    Stack Membro Participativo

    When I set the background color of items in my QTableWidget using item.setBackground(QColor(210,210,210)), the color doesn't fill the cell entirely, there is some sort of padding with rounded corners : image

    Is there a way to get rid of that "rounded style"? The person in this post is also using .setBackground() but doesn't have this issue.

    WHAT I TRIED :

    When using QSS to change the background color of the table items, all the cells are filled-in correctly (image), however I want to be able to choose which rows to apply the background color to.

    QTableView::item {
    color: rgb(50,50,50);
    background-color: rgb(0,180,0);
    }
    QTableView {
    background-color: rgb(240, 240, 240);
    font: 16px;
    }


    I also tried to fiddle with the border and padding, but it just removes all background colors, no matter the values.

    QTableView::item {
    color: rgb(50,50,50);
    border: 0px;
    padding: 4px;
    }

    Continue reading...

Compartilhe esta Página