Rendering flat QPushButton inside QTreeWidget



  • I have a QTreeWidget with 4 rows: inside third and fourth, i want to set a customized QPushButton. It's flat, it has no text, I want it to be visible for its background color, but it doesn't show. It's background color is only visible when pressed. Documentation for setItemWidget says:

    bq. The given widget's autoFillBackground property must be set to true, otherwise the widget's background will be transparent, showing both the model data and the tree widget item.

    yet a flat QPushButton doesn't paint properly. Example code:
    @
    QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget);
    item->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled);
    item->setText(0, "Nombre tarea");
    QSpinBox *sb = new QSpinBox;
    treeWidget->setItemWidget(item, 1, sb);
    QPushButton *colorTexto = new QPushButton("");
    colorTexto->setFlat(true);
    colorTexto->setAutoFillBackground(true);
    QPushButton *colorFondo = new QPushButton("");
    colorFondo->setFlat(true);
    colorFondo->setAutoFillBackground(true);
    treeWidget->setItemWidget(item, 2, colorTexto);
    treeWidget->setItemWidget(item, 3, colorFondo);
    @

    Here's an example !http://imgur.com/VMZKizn : mouse doesn't appear, i'm pressing the colored square, that's why it shows, but if I release button, it becomes invisible, like the one on the fourth column.

    [EDIT - ACTUALIZATION ]: if the button is not flat, "it works better ":http://imgur.com/tbxwc1s but still isn't what I want, I'd prefer a flat button


Log in to reply
 

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