QT:4.1.1

Hello everybody,

I am trying to call a function by clicking on a item with the signal: itemClicked()
It happens nothing beim clicking on a item. Can somebody see what is wrong:

Qt Code:
  1. MainWindow::MainWindow()
  2.  
  3. {
  4. ui.setupUi(this);
  5.  
  6.  
  7. connect(ui.tabellen_cb, SIGNAL(currentIndexChanged (int)), this, SLOT(selectTable()));
  8. connect(ui.actionverbinden, SIGNAL(triggered()), this, SLOT(openLoginDialog()));
  9. connect(ui.actionNeu, SIGNAL(triggered()), this, SLOT(insertNewRow()));
  10. connect(ui.abfrage_btn, SIGNAL(clicked()), this, SLOT(selectTable()));
  11. connect(ui.new_btn, SIGNAL(clicked()), this, SLOT(insertNewRow()));
  12. connect(ui.delete_btn, SIGNAL(clicked()), this, SLOT(deleteRow()));
  13. connect(ui.abfrage_btn, SIGNAL(clicked()), this, SLOT(addItemsToTreeWidget()));
  14.  
  15.  
  16. QTreeWidgetItem *root = new QTreeWidgetItem(ui.tree);
  17. QTreeWidgetItem *tables = new QTreeWidgetItem(root);
  18. connect(ui.tree, SIGNAL(itemClicked (tables,0)), this, SLOT(selectTable()));
  19.  
  20.  
  21. init();
  22.  
  23. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. void MainWindow::selectTable()
  2. {
  3. /*
  4. QString table = ui.tabellen_cb->currentText();
  5. QSqlTableModel *model = new QSqlTableModel;
  6.   model->setTable(table);
  7.   //So kann man jeder Feld update: OnFiledChange
  8.   model->setEditStrategy(QSqlTableModel::OnFieldChange);
  9.   model->select();
  10.  
  11.  
  12.   ui.tableView->setModel(model);
  13.   ui.tableView->show();
  14.   */
  15. QTreeWidgetItem *root = new QTreeWidgetItem(ui.tree);
  16. root->setIcon(0, QIcon(QString::fromUtf8(":/images/images/database.jpg")));
  17. root->setText(0, "inventar");
  18.  
  19. QTreeWidgetItem *tables = new QTreeWidgetItem(root);
  20. tables->setIcon(0, QIcon(QString::fromUtf8(":/images/images/table.jpg")));
  21. tables->setText(0, "tabellen");
  22. QString table = tables->text(0);
  23. QMessageBox::information(this,"",table);
  24. model->setTable(table);
  25. //So kann man jeder Feld update: OnFiledChange
  26. model->setEditStrategy(QSqlTableModel::OnFieldChange);
  27. model->select();
  28.  
  29.  
  30. ui.tableView->setModel(model);
  31. ui.tableView->show();
  32.  
  33. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. void MainWindow::addItemsToTreeWidget()
  2. {
  3. ui.tree->clear();
  4. ui.tree->setObjectName(QLatin1String("ui.tree"));
  5. ui.tree->setHeaderLabels(QStringList(tr("database")));
  6. // ui.tree->header()->setResizeMode(QHeaderView::Stretch);
  7.  
  8. QTreeWidgetItem *root = new QTreeWidgetItem(ui.tree);
  9. root->setIcon(0, QIcon(QString::fromUtf8(":/images/images/database.jpg")));
  10. root->setText(0, "inventar");
  11.  
  12. QTreeWidgetItem *tables = new QTreeWidgetItem(root);
  13. tables->setIcon(0, QIcon(QString::fromUtf8(":/images/images/table.jpg")));
  14. tables->setText(0, "tabellen");
  15.  
  16. QSqlQuery select("select * from sysobjects where xtype = 'U' order by name");
  17. while(select.next())
  18. {
  19. QString tabelle = select.value(0).toString();
  20. //new QTreeWidgetItem(tables, tabelle, 0);
  21. QTreeWidgetItem *items = new QTreeWidgetItem(tables);
  22. items->setText(0, tabelle);
  23. items->setIcon(0, QIcon(QString::fromUtf8(":/images/images/table.jpg")));
  24.  
  25. }
  26.  
  27. }
To copy to clipboard, switch view to plain text mode