Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

QTreeView slot on selection change

$
0
0
Hiho everybody, I want to connect a QTreeView to a slot, so that I can call a function every time I click on a row of this treeview. The problem is that it doesn’t work and I dont know why. Here is what I have: QStandardItemModel* model = new QStandardItemModel(frame); QStandardItem* terrain = new QStandardItem(QIcon("../media/icon_crosshairs16x16bw1.gif"), "Terrain");  QStandardItem* ground = new QStandardItem(QIcon("../media/icon_crosshairs16x16bw1.gif"), "Ground");  QStandardItem* water = new QStandardItem(QIcon("../media/icon_crosshairs16x16bw1.gif"), "Water"); //some more items terrain->setFlags(terrain->flags() & ~Qt::ItemIsEditable); ground->setFlags(ground->flags() & ~Qt::ItemIsEditable); water->setFlags(water->flags() & ~Qt::ItemIsEditable);    //to prevent the user from modifying the text of the selection   model->appendRow(terrain); terrain->appendRow(ground); terrain->appendRow(water);   QTreeView * treeView = new QTreeView(frame); treeView->setModel(model); I dont know if that is the right way to create an expandable treeview but at least this works :) And now the part where I think the problem is: QObject::connect(treeView->selectionModel(), SIGNAL(itemChanged ( QStandardItem * item )), MainWindow, SLOT(slot_selectionChanged())); I hope somebody can help be. Thanks in advance and best regards, Ritschratsch

Viewing all articles
Browse latest Browse all 18427

Trending Articles