Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Rendering flat QPushButton inside QTreeWidget
Qt 6.11 is out! See what's new in the release blog

Rendering flat QPushButton inside QTreeWidget

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Marcos Modenesi
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved