While double-clicking the text of a QTreeView expands the children, a single-click does not. The icon defined in the CSS (and placed to left of text) expands the children on a single-click, though. How do I make it so a single-click (or touch event) of the text will expand the children?
bookTreeView->setModel(standardModel);
bookTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
bookTreeView->setWordWrap(true);
bookTreeView->sizeHint();
//bookTreeView->mousePressEvent(QMouseEvent());
bookTreeView->setTextElideMode(Qt::ElideNone);
bookTreeView->setExpandsOnDoubleClick(true);
bookTreeView->setUniformRowHeights(true);
bookTreeView->setHeaderHidden(true);
bookTreeView->setStyleSheet("QTreeView { font-size: 27px; show-decoration-selected: 0; } QTreeView::branch:has-siblings:!adjoins-item { border-image: none; } QTreeView::branch:has-siblings:adjoins-item { border-image: none; } QTreeView::branch:!has-children:!has-siblings:adjoins-item { border-image: none;} QTreeView::branch:has-children:!has-siblings:closed, QTreeView::branch:closed:has-children:has-siblings { border-image: none; image: url(':images/images/right_arrow.png'); } QTreeView::branch:open:has-children:!has-siblings, QTreeView::branch:open:has-children:has-siblings { border-image: none; image: url(':images/images/down_arrow.png'); } ");
Something along the lines of
The
clickedsignal might not do what you want. You can also have a look at thecurrentChangedsignal, which might be what you want. I’ve never used Qt in a mobile context 🙂