Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Tags
    3. qtreeview
    Log in to post

    • SOLVED QTreeView drag/drop "icon" Transparency
      General and Desktop • qtreeview qdrag qdrag drag drop indicator • • Dariusz  

      5
      0
      Votes
      5
      Posts
      45
      Views

      @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.
    • SOLVED Do I need to call deleteLater() function if QTreeView has widget ownership?
      General and Desktop • qtreeview qstandarditemmo deletelater removerow setindexwidget • • Yash001  

      5
      0
      Votes
      5
      Posts
      32
      Views

      @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.
    • UNSOLVED Partial text selection in QTreeView
      General and Desktop • qtreeview qt4.8 selection • • Giert  

      7
      0
      Votes
      7
      Posts
      54
      Views

      @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
    • SOLVED Create Filter for QStandardItemModel
      General and Desktop • qtreeview qstandarditemmo • • Kita  

      4
      0
      Votes
      4
      Posts
      57
      Views

      Yes, you are in charge of writing the GUI part.
    • UNSOLVED QTreeView: specify distance between branch image and text/decoration
      General and Desktop • c++ qtreeview styles • • hoafaloaf  

      3
      0
      Votes
      3
      Posts
      55
      Views

      @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? :)
    • UNSOLVED QTreeView in single line format
      General and Desktop • qtreeview • • avmg  

      5
      0
      Votes
      5
      Posts
      69
      Views

      Thanks VRonin, that is probably easier.
    • SOLVED QTreeView with QSortFilterProxyModel extremly slow with many (~5000) items
      General and Desktop • qtreeview qsortfilterprox slow • • gde23  

      4
      0
      Votes
      4
      Posts
      64
      Views

      @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 :)
    • UNSOLVED How to recognize padding for a QTableView table item?
      General and Desktop • qtreeview style item padding • • xintrea  

      2
      0
      Votes
      2
      Posts
      219
      Views

      @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)?
    • UNSOLVED File Browser with context menu to unzip files
      General and Desktop • qtreeview qfiledialog qfilesystemmode • • mahesh_j  

      7
      0
      Votes
      7
      Posts
      257
      Views

      @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/
    • UNSOLVED QTreeView focus events and losing selection
      General and Desktop • qtreeview • • Dariusz  

      4
      0
      Votes
      4
      Posts
      394
      Views

      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; }
    • SOLVED QTreeView disable scroll to letter match...
      General and Desktop • qtreeview • • Dariusz  

      4
      0
      Votes
      4
      Posts
      71
      Views

      @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 :- )
    • UNSOLVED Replace QTreeView::branch using pixmap ?
      General and Desktop • qtreeview qpainter qpixmap • • Dariusz  

      12
      0
      Votes
      12
      Posts
      132
      Views

      Then maybe QTreeView::drawBranches is what you are looking for.
    • UNSOLVED QTreeView branch drawing... missing branch?
      General and Desktop • qtreeview qstyle • • Dariusz  

      5
      0
      Votes
      5
      Posts
      275
      Views

      In fact, it's the QTreeView::drawBranch that handles that.
    • SOLVED QTreeView remove dotted line when selected
      General and Desktop • qtreeview qstyleditemdele qstylesheet • • Dariusz  

      5
      0
      Votes
      5
      Posts
      424
      Views

      Thanks @SeitsemaN for this solution, *{outline: none;} This works well. I wasted like 8hrs on this.
    • SOLVED QStyledItemDelegate - implement drag event?
      General and Desktop • qtreeview qstyleditemdele qdrag qdrag drag drop • • Dariusz  

      2
      0
      Votes
      2
      Posts
      120
      Views

      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!
    • UNSOLVED QTreeView - from bottom to top ?
      General and Desktop • qtreeview • • Dariusz  

      4
      0
      Votes
      4
      Posts
      100
      Views

      @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 :- )
    • UNSOLVED QTreeView selected item color when out of focus... style...
      General and Desktop • qtreeview qstandarditem qstylesheet • • Dariusz  

      2
      0
      Votes
      2
      Posts
      262
      Views

      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.
    • SOLVED QTreeView ghost select parent if child selected?
      General and Desktop • qtreeview • • Dariusz  

      9
      0
      Votes
      9
      Posts
      789
      Views

      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!
    • SOLVED Using methods from private classes
      General and Desktop • qtreeview • • eska2000  

      5
      0
      Votes
      5
      Posts
      274
      Views

      @mrjj My task is to drag items from QTreeView to another widget. But when I try to drag item this item makes selected. I need to drag items without selection them. So I want to reimplement mousePressEvent. But I still need to collapse/expand items, so if I reimplement mousePressEvent I need to see which area of the item (string or sign) user pressed.
    • UNSOLVED QTreeView setRootIndex & changing header - incorrect columnCount...?
      General and Desktop • qtreeview qheaderview • • Dariusz  

      6
      0
      Votes
      6
      Posts
      355
      Views

      I'm using abstractItemModel / my own item, I ensure that columnCount return correct number of columns, yet it's still wrong. In regard to using proxyModels, I'd love to use it, but I only found few examples and I'm struggling as to how I would do it. Any hints wold be great, I would prefer to use a proxy instead here. I literally have no idea how I can simulate setRootIndex with proxyModel, since I need to see parentItem of the item that I wish to set as rootitem and I don't want to see these parent items... here was me early attempt > https://forum.qt.io/topic/102227/qsortfilterproxymodel-simulate-new-root-index/2 @Christian-Ehrlicher I'm totally blaming you for me going this setRootIndex road as I was trying proxy early and you said to use this : p
    • UNSOLVED Settings widget into focus programmatically.
      General and Desktop • qwidget qtreeview qcombobox • • Dariusz  

      9
      0
      Votes
      9
      Posts
      662
      Views

      That article answers quite a few questions I had about that scenario, woah nice thanks! But... I kinda like the idea of more "control"... somehow, creating the widget this way allow the user to resize it which won't be possible using a popup, so I would like to get the focus to work properly... TIA
    • SOLVED QTreeView drag/drop action change between in/out of view?
      General and Desktop • qtreeview qdrag • • Dariusz  

      1
      0
      Votes
      1
      Posts
      138
      Views

      No one has replied

    • UNSOLVED QTreeView & QStyledItemDelegate & QPushButton/Checkbox etc?
      General and Desktop • qtreeview qpushbutton qstyleditemdele checkbox • • Dariusz  

      20
      0
      Votes
      20
      Posts
      3141
      Views

      Hey Got a follow up question in regards to styling... How can I get QComboBox focus indicator/rect ? So that I can set correct color for the outline of comboBox to paint? I tried using QRect r = QApplication::style()->subElementRect(QStyle::SE_ComboBoxLayoutItem, &option, mWidgetList[ComboBox]); and QRect r = QApplication::style()->subElementRect(QStyle::SE_ComboBoxFocusRect, &option, mWidgetList[ComboBox]); But neither return correct rect to use as paint target... Only the large square one around item in tree view. Any hints? Same for QPushButton, and pretty much any button/combo like widget I think o.O TIA.
    • UNSOLVED QTreeView dropping on item - filtering ?
      General and Desktop • qtreeview qdrag qdrop • • Dariusz  

      6
      0
      Votes
      6
      Posts
      500
      Views

      I've wrote 1 treeView/model system last year that had it all re-implemented from scratch, a few days ago I decided to rewrite it to increase performance and relay more on native functions of QT. Which I did and works great but the margin thing is a sticking point. I remember how much work it was before to get it to work properly... took a while as I had to write quite a few functions before I got to the point of margin detection. I'm very surprised there is no margin = (qt code ) + userMarginOverrideVal in the canDrop() function... this would have allowed us to just say, hey add +5 pixels to detection or something like that... Perhaps I should add it to feature request, would posting it in a bug report tracker be a good place? I don't see feature requests and I have no idea how to get the source to compile (Just didn't spend enough time on it) and add it myself & post to qt as commit... As far as I can tell we need like 2 functions, setOverrideMargin(int val) and getOverrideMargin(), skipping setting flag true/false if we want to use it as defaultVal should just be 0... TIA
    • SOLVED QTreeView/Model drop action - no expand sign ?
      General and Desktop • qtreeview qabstractitemmo qdrag qdrop • • Dariusz  

      3
      0
      Votes
      3
      Posts
      323
      Views

      @raven-worx said in QTreeView/Model drop action - no expand sign ?: Also did you emit the dataChanged() signal on the parent index? I've just read the post. I forgot to correct it. This is what I edit: bool testModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { ... Q_EMIT dataChanged(itemFirst.index(),itemLast.index()) } Hmmmm so I tried this, the parent is the object that is in function above. Q_EMIT dataChanged(parent, parent) Now this now "magically" works, I get extra ">" when I drop item on another item... I also learned that I also need to call Q_EMIT layoutChanged({parent}/flag) to update view if I drop items on expanded parent... Ok all good then, thanks! Weird issue o.o
    • UNSOLVED Model view widget with different root item ?
      General and Desktop • qtreeview qabstractitemmo qstandarditemmo • • Dariusz  

      9
      0
      Votes
      9
      Posts
      584
      Views

      @SGaist Woah... I have lots to read! Thanks! Gotta dig into proxier more then.
    • UNSOLVED Animation of QItemDelegates
      General and Desktop • qtreeview animation qitemdelegate • • H. Krishnan  

      4
      0
      Votes
      4
      Posts
      331
      Views

      Hi, One alternative could be to use QRubberBand and draw it on top of the lines/cells you are interested in.
    • UNSOLVED Expose custom parameters to QSS
      General and Desktop • qwidget qtreeview qss custom • • b2soft  

      8
      0
      Votes
      8
      Posts
      900
      Views

      @b2soft I want to customize BrowserModel ::data() returning colors using QSS @raven-worx knows much more than I, but I don't get this. role == Qt::TextColorRole will want to return a QBrush (http://doc.qt.io/qt-5/qt.html#ItemDataRole-enum). How is that linked to returning a string to use for a name in a stylesheet? :confused:
    • SOLVED QTreeView add widget below/around the widget from within QTreeView widget...
      General and Desktop • qwidget qtreeview • • Dariusz  

      12
      0
      Votes
      12
      Posts
      1109
      Views

      Ok so after LOTS of fighting with QTreeView... I started looking at viewport() and wuaila! void myTree::resizeEvent(QResizeEvent *event) { QAbstractItemView::resizeEvent(event); b->setFixedSize(event->size().width(), 25); b->move(0,height()-25); viewport()->setMaximumHeight(height() - 50); }; Now my viewport gets painted exactly where I want it to, and the extra buttons can be placed in area where I want it to (b is the button) + its all nice all in one widget. I can expose needed controls for b as pert spec but drawing is as it should. Yay!
    • UNSOLVED Multithreading conversion of QModelIndexList to treeItem crash
      General and Desktop • qtreeview qmodelindex qmodelindexlist • • Dariusz  

      4
      0
      Votes
      4
      Posts
      675
      Views

      @Dariusz said in Multithreading conversion of QModelIdnexList to treeItem crash: Well I have 100k items +/- to deal with Then you should avoid to dereference the pointers to not copy the data around. I created the base vectors via QVector<myTreeNode> vec(vecSize) and I access them all via [], so no thread should step over another thread, It does as your backtrace shows. Since you're using QVector which is implicit shared every write access to the container checks if the container needs to get detached. Maybe try with a non-implicit shared container instead (e.g. a std::vector) See http://doc.qt.io/qt-5/implicit-sharing.html for details.
    • UNSOLVED Tree view for hierarchical SQL query?
      General and Desktop • qtableview sql qtreeview software design presentation • • elfring  

      3
      0
      Votes
      3
      Posts
      537
      Views

      I'll update this post once I go anywhere with it This feedback sounds promising. I am becoming more curious around another description for a similar use case: An associative table can be created. QStandardItem objects can be generated then based on table entries. Which ways would you like to recommend for the connection of entities to their relationship data?
    • UNSOLVED QTreeView in QTreeWidgetItem
      General and Desktop • qtreeview qtreewidget qtreewidgetitem adjusttocontent • • Craetor  

      8
      0
      Votes
      8
      Posts
      1228
      Views

      @JonB This code is a small example to find solution. In my real project i need to show tree with different items and nested trees.
    • SOLVED Reimplementing QFileSystemModel Checkboxes using QMap inconsistent results
      General and Desktop • qtreeview qabstractitemmo qsortfilterprox qfilesystemmode • • moffa13  

      15
      0
      Votes
      15
      Posts
      1156
      Views

      Ok I found what was causing this awful bug. When I check if the map contains the index, I actually check the raw index not the QPersistantModelIndex so this is not the same object and I think qmap does not check equality using == operator . So I have to iterate over the map and check using QPersistantModelIndex "==" operators which can compare from a QModelIndex.
    • UNSOLVED Tree View with varying column counts
      General and Desktop • qtreeview model model-view treemodel • • DaveK 0  

      1
      0
      Votes
      1
      Posts
      348
      Views

      No one has replied

    • UNSOLVED QTreeView store expanded state - long ?
      General and Desktop • qtreeview qabstractitemmo expanded isexpanded • • Dariusz  

      2
      0
      Votes
      2
      Posts
      417
      Views

      Hey Just thoguh I'd drop a "temporary" solution I'm testing now. I ended up extending qtreeView, and capturing expand/collapse signals. Then I generate a QSet with these ids that later I can store/restore via model()->match(id) idea. Not sure how well it will work in very large data sets, say 100k items and 10k expanded state items, But well see.
    • UNSOLVED QTreeView - rename notify
      General and Desktop • qtreeview qstandarditemmo qstandarditem • • Dariusz  

      4
      0
      Votes
      4
      Posts
      895
      Views

      What model are you using? QStandardItemModel had the roles argument working from Qt 5.11 onward. An empty role vector implies "all roles changed"
    • SOLVED QTreeView, QAbstractItemModel and internal move
      General and Desktop • qtreeview drag and drop itemmodel • • Athius  

      5
      1
      Votes
      5
      Posts
      2600
      Views

      @Athius Sure it works, here my code for a bookmark tree: bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { Q_UNUSED(column) if(action EQ Qt::IgnoreAction) return false; if(action EQ Qt::MoveAction) { QByteArray bytes=data->data(MIME_Bookmark); QDataStream stream(&bytes,QIODevice::QIODevice::ReadOnly); qintptr i; int r,c; stream>>i>>r>>c; QModelIndex index=createIndex(r,c,i); moveRow(index,index.row(),parent,row); } return true; } Of course you need to create and return your custom data in mimeData () as well.
    • UNSOLVED Padding/Margin is not applied to last two elements in QTreeView
      General and Desktop • stylesheet qtreeview qtreewidget • • JoseTomasTocino  

      6
      0
      Votes
      6
      Posts
      2475
      Views

      A late reply, but it looks like those elements are different in that they don't have children. Have you checked that you don't have a style with QTreeView::item:!has-children { padding: ... } defined anywhere which could be overriding the style when applied at the branch level?