Greetings, I'm trying to make a search form for my QTreeWidget.
My problem is that when the current selection changes it does a database operation to populate a tableview and it crashes.
After a bit of debugging I figured that the problem is that
Qt Code:
  1. // Item is a QString that 100% exists on the tree
  2. QTreeWidgetItem *selected = ui->tree->findItems(item,Qt::MatchExactly | Qt::MatchRecursive | Qt::MatchWrap)[0];
  3. selected->setSelected(true); // This selects the node on the tree successfully (visually)
  4. qDebug() << ui->tree->currentItem(); // However this returns 0x0 until I click on the already selected item, then it returns the mem address correctly.
To copy to clipboard, switch view to plain text mode 
I'm a bit confused why is it happening? The tree emits the signal that the current item changes, but when I attempt to retrieve the new current item it returns an invalid pointer.
Thanks in advance for all replies.