How to make QTreeWidgetItem Unclickable
-
Hi , i have many QTreeWidgets also QTreeWidgetItems and i wanna make the parent in every QTreeWidget unclickable but the child is okey so i used
item1_AddingItemstoTreeWidget_3->setFlags(item1_AddingItemstoTreeWidget_3->flags() & ~Qt::ItemIsSelectable );
but it makes the item clickable and if i click it gives NULL value and this makes the software crashes and the process as following : Two TreeWidgets in the page and if click an item in first one will be added to the second Tree then save it in database and This Null or empty block for Serum so i wanna make parents unclickable .. Thanks in Advance
this an image : "https://ibb.co/qYThprS" -
Hi,
What is the stack trace of your crash ?
-
@SGaist
Actually the second TreeWidget items appending in a vector so it inserted a NULL value that makes software crashes when i click "Cancel" button , so i wanna prevent this by make the parents unclickable (that if th user click not added not the second TreeWidget coz the first TreeWidget adding items by DoubleClick ) but all answers i found about disable and isSelectable and i tried them and don't serve my Request -
Hi
Did you try with removing
Qt::ItemIsEnabled ? -
@mrjj
i tried this too , but i don't need isSelectable or isEnabled because it also makes the item clickable , Actually i have function for the first TreeWidget .. on_treeWidget_itemDoubleClicked()
but i wanna only the parents be unclickable .. can this be achived ?
this image after displaying Qt::ItemIsEnabled : "https://ibb.co/S0RSZ4q" -
What about the solution proposed in this stack overflow thread ?
-
@SGaist
i tried it after seeing on Stackoverflow from your comment but it didn't work either , also i saw a link for same request and useditem1_AddingItemstoTreeWidget_3->setFlags(item1_AddingItemstoTreeWidget_3->flags() & ~Qt::NoItemFlags );
also didn't work