Skip to content
  • 0 Votes
    4 Posts
    2k Views
    VRoninV
    @ralphtink said in How to flatten a TreeView to show only the leaf node items?: I don't want to import a whole library just for this I would strongly suggest you do but even if you want to go against my advice you can just: take kbihash_p.h, kdescendantsproxymodel.h and kdescendantsproxymodel.cpp add the files to your project replace #include "kitemmodels_export.h" with #define KITEMMODELS_EXPORT satisfy LGPL 2 requirement on the imported code
  • 0 Votes
    12 Posts
    2k Views
    J
    Okay, I had absolutely believed that I had tried making the call to my savePos() function to try to diagnose whether the signal had something to do with it, yet when I disable the connect()ion altogether and call it explicitly, now these APIs want to behave like good little children and do what they're supposed to. So, essentially I shot myself in the foot by handling this with modelAboutToBeReset(), which implicitly trashes the internal cache of visible indexes. D'oh! Argh, etc. Thanks for the help, folks.
  • 0 Votes
    5 Posts
    1k Views
    D
    @raven-worx said in QTreeView drag/drop "icon" Transparency: @Dariusz the only way currenlty is to start the drag entirely yourself by overwriting QAbstractItemView::startDrag() Its not that hard. Simply get the data for all selected indexes from the model and set a custom drag pixmap and call QDrag::exec() Hey Id love to do it but sadly it does not work. For example > def startDrag(self, supportedActions): d = QDrag(self) data = self.model().mimeData(self.selectedIndexes()) d.setMimeData(data) d.exec_(supportedActions) It Will, not produce the same effect as native action. Simply because when you look at source code where > if (drag->exec(supportedActions, defaultDropAction) == Qt::MoveAction) d->clearOrRemove(); Which handles the items state after their drag. I can not reproduce the action without a large rewrite of the startDrag event I'm afraid. I wish that the function that they use for Pixmap generation > QPixmap pixmap = d->renderToPixmap(indexes, &rect); rect.adjust(horizontalOffset(), verticalOffset(), 0, 0); QDrag *drag = new QDrag(this); drag->setPixmap(pixmap); Would be a virtual function so that I can overwrite it and provide my own pixmap at that level without messing up entire drag Qt logic.
  • 0 Votes
    5 Posts
    1k Views
    JonBJ
    @Yash001 When items are removed from a model the view will update to reflect the new state. Widgets you have added via setIndexWidget() which are no longer present will be deleted by Qt infrastructure without you needing to delete them or disconnect from signals.
  • Partial text selection in QTreeView

    Unsolved General and Desktop qtreeview qt4.8 selection
    7
    0 Votes
    7 Posts
    2k Views
    G
    @SGaist of course! This OP gave up, as I'm about to do while this discussion gave me hope of handling mouse events in the view myself This discussion didn't really go anywhere at all
  • Create Filter for QStandardItemModel

    Solved General and Desktop qstandarditemmo qtreeview
    4
    0 Votes
    4 Posts
    1k Views
    SGaistS
    Yes, you are in charge of writing the GUI part.
  • 0 Votes
    3 Posts
    903 Views
    H
    @JonB Thanks for the suggestion, but I did check that out -- it looks like setIndentation()/indentation() only deals with the space to right of the expand/collapse arrow (i.e., the ::branch subcontrol). Any other ideas? :)
  • QTreeView in single line format

    Unsolved General and Desktop qtreeview
    5
    0 Votes
    5 Posts
    470 Views
    A
    Thanks VRonin, that is probably easier.
  • 0 Votes
    4 Posts
    1k Views
    Christian EhrlicherC
    @gde23 said in QTreeView with QSortFilterProxyModel extremly slow with many (~5000) items: Thanks for demanding a minimal example :) Thx for trying to create one - sadly a lot of people don't understand the demand for this but this here is a good example why it's needed :)
  • 0 Votes
    2 Posts
    2k Views
    Christian EhrlicherC
    @xintrea said in How to recognize padding for a QTableView table item?: not the default style. Only the stylesheet style provides a padding (see box model), all other styles don't have a 'padding' value at all. So what do you want exactly (and why)?
  • 0 Votes
    7 Posts
    2k Views
    jsulmJ
    @mahesh_j said in File Browser with context menu to unzip files: But I don't know what actions to add to the QMenu The actions you need. You have to create such a pop-up menu. Take a look at http://quazip.sourceforge.net/
  • QTreeView focus events and losing selection

    Unsolved General and Desktop qtreeview
    4
    0 Votes
    4 Posts
    2k Views
    CKurduC
    You can subclass QTreeView and override setSelection. Firstly don't forget to set the multiselection mode. view->setSelectionMode(QAbstractItemView::MultiSelection); Override the setSelection method. #define MAX_SELECT 3 void TreeView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) { if(command & QItemSelectionModel::Deselect) { QTreeView::setSelection(rect,command); return; } if(command & QItemSelectionModel::Clear) { //Actually purpose this "if branch" to disable clear //but MultiSelection mode already do that so execute below command is normal. QTreeView::setSelection(rect,command); return; } QModelIndexList ls = this->selectedIndexes(); int total = 0; for(int i=0; i< ls.size();i++) { if(ls[i].column() != 0) continue; QModelIndex p = ls[i].child(0,0); if(!p.isValid()) { //I think when p is invalid ls[i] doesn't have any child. Maybe there is an another way to find this. total++; }else{ QString child_data = p.data().toString(); } } if(total < MAX_SELECT ) { QTreeView::setSelection(rect,command); }else{ //You can scroll here. } return; }
  • QTreeView disable scroll to letter match...

    Solved General and Desktop qtreeview
    4
    0 Votes
    4 Posts
    548 Views
    D
    @mrjj I prefer to be able to press F to zoom in to selected items as the selection might happen in another widget. Look at 3d apps with scenegraphs. They don't use search by key. @Christian-Ehrlicher said in QTreeView disable scroll to letter match...: @Dariusz said in QTreeView disable scroll to letter match...: How can I disable this ? OVerwrite QAbstractItemView::keyboardSearch() Thanks! Sounds like that might be it :- )
  • Replace QTreeView::branch using pixmap ?

    Unsolved General and Desktop qpixmap qtreeview qpainter
    12
    0 Votes
    12 Posts
    2k Views
    SGaistS
    Then maybe QTreeView::drawBranches is what you are looking for.
  • QTreeView branch drawing... missing branch?

    Unsolved General and Desktop qtreeview qstyle
    5
    0 Votes
    5 Posts
    2k Views
    SGaistS
    In fact, it's the QTreeView::drawBranch that handles that.
  • 0 Votes
    5 Posts
    3k Views
    S
    Thanks @SeitsemaN for this solution, *{outline: none;} This works well. I wasted like 8hrs on this.
  • 0 Votes
    2 Posts
    797 Views
    D
    Yo It appears that I was almost there... just need to create a proper drag! def initializeDrag(self, event, option, index): self.dragInitialized = True print("Drag initialized!") drag = QDrag(self) mim = QMimeData() mim.setText("yoyoyooy") drag.setMimeData(mim) val = drag.exec_() print("Return drag val : ", val) self.dragInitialized = False Once thats made, I then have to handle dragEnterEvent on QTreeView and then pass it to proper function from there... yay!
  • QTreeView - from bottom to top ?

    Unsolved General and Desktop qtreeview
    4
    0 Votes
    4 Posts
    492 Views
    D
    @Pl45m4 said in QTreeView - from bottom to top ?: @Dariusz How should the TreeView know where to put the first item, when there is no item inside (Spacing etc). What kind of items / data do you have in your TreeView? You could insert new branches above the top-most existing one manually. The item would start at bottom and every new item would go above previous item. @mrjj said in QTreeView - from bottom to top ?: Hi Can i ask what use the case is? I never saw such a flipped tree. Also the scrolling would be very confusing. :) For example photoshop, has top-down relationship where layer above occludes layer below. It would make sense then to grow layers from bottom not from top :- )
  • 0 Votes
    2 Posts
    2k Views
    Chris KawaC
    which style parameter do I have to edit to control the color of item when the widget loses focus? QTreeView::item:active { color: red; } /* When widget has focus*/ QTreeView::item:!active { color: blue; } /* When widget doesn't have focus*/ if I do show-decoration-selected: 1; How do I control decoration color ? It depends on the platform styling. For example on Windows it only colors on hover the little arrow that expands/collapses the branch and that arrow is painted by a system style call so you can't control its color. You can however replace the system styling and change the branch images to your own with any color you like. See Customizing QTreeView for examples.
  • QTreeView ghost select parent if child selected?

    Solved General and Desktop qtreeview
    9
    0 Votes
    9 Posts
    3k Views
    D
    Well my ASAP took a lot longer than I thought... anyway I went with Method 1 and it works like charm! Thank you so much! The only thing I had to tweak was to call update() at the end of mouse release, as apparently, the selection flag in my scenario was happening after selection, so when the painter was painting items the child was not marked selected... after that it all tick! TIA!