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. Add two clickable icons to one item in treeview
Forum Updated to NodeBB v4.3 + New Features

Add two clickable icons to one item in treeview

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 191 Views
  • 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.
  • W Offline
    W Offline
    WhichOneCanIDo
    wrote on last edited by WhichOneCanIDo
    #1

    i want to show two icons in one item line ,and the icons can be clickable ,my code is used to be one checkbox to provide one function, but now i need two.

    QVariant TreeItem::data(const QModelIndex & index, int role) const{
    QVariant output;
    if (role == Qt::CheckStateRole) {
                if (node->IsSelectable()) {
                    return Qt::CheckState::Checked;
                } else {
                    return Qt::CheckState::Unchecked;
                }
    }
    

    this code is how the checkbox show,i want to use

    else if (role == Qt::DecorationRole) {
                QPixmap Icon = QPixmap(":/.../...");
                output.setValue(Icon);
            }
    

    there is only one icon.
    (icon1) (icon2)text
    is what i want
    or can i use delegate to add two pushbutton ?

    1 Reply Last reply
    0
    • gde23G Offline
      gde23G Offline
      gde23
      wrote on last edited by
      #2

      If you are ok with two columns then the easiest way would be to just have two columns with your item, and each of them is cheackable.
      If you want to have everything in one column cell, then you need to go for a delegate.
      The delegate then can be any widget e.g. a QWidget with two QToolButtons and a QLabel on it.

      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