[Qt-interest] connect doesn't work

Stephen Jackson spjackson42 at gmail.com
Sat Apr 4 06:35:00 CEST 2009


On 4/4/09, enjoywm wrote:
> Hi,
>
>  I use QTreeWidget and set the connect like the following. However, when I
>  click one the item nothing happen.
>
>
>  void MainWindow::initialTreeWidget()
>  {
>  ...
>  connect(treeWidget, SIGNAL(itemClicked ( QTreeWidgetItem * item, int
>  column )), SLOT(updateView(QTreeWidgetItem * item, int column)));
>
>  ...
>  }
>
>
>  void MainWindow::updateView(QTreeWidgetItem * item, int column)
>  {
>         QMessageBox::warning(this, tr("Warning"), tr("ok"));
>  }
>
>  Thanks.

This is a common mistake. Do not name the parameters to the SIGNAL and
SLOT macros. i.e.

connect(treeWidget, SIGNAL(itemClicked ( QTreeWidgetItem *, int
 )), SLOT(updateView(QTreeWidgetItem * , int )));

Regards,

Stephen Jackson



More information about the Qt-interest-old mailing list