[Qt-interest] Fwd: problem with signal of QListWidget

Stephen Jackson spjackson42 at gmail.com
Mon Jun 22 17:39:48 CEST 2009


On Mon, Jun 22, 2009 at 6:12 AM, mierdatutis mi wrote:
> Sorry Stephen
>
> I'm newbie and I havent realised.
> The ui have:
>
> object:Mainwindow Class:QMainWindow
> object centralwidget: class: QWidget
> object: boton class QPushButton
> object: lista class QListWidget
> object: text class QTextEdit
>
> I attach the ui file
>
> Many thanks!!!!
> Regards
>
>

Thanks. Now we have all the relevant source, we can see what is going on.

When your application runs, 3 top level windows are shown, each of
which is created in main() thus.
  MainWindowImpl win;
  QTextEdit text;
  QListWidget lista;

In main() you populate this lista with the contents of a directory.

Your MainWindowImpl has a number of child widgets, one of which is a
QListWidget called "lista". This lista contains no items and this is
the one that you are connecting your slot to. If you add some items to
it and click one of these, then your cambio() slot is indeed called.
e.g.

MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f)
: QMainWindow(parent, f)
{
   setupUi(this);
   lista->addItem("This");
   lista->addItem("is");
   lista->addItem("MainWindowImpl::lista");
   connect(boton, SIGNAL(clicked()), this, SLOT(sinopsis()));
   connect(lista, SIGNAL( itemClicked(QListWidgetItem*) ), this, SLOT(
cambio(QListWidgetItem*) ) );
}

I hope this helps you solve this problem.

Regards,

Stephen Jackson



More information about the Qt-interest-old mailing list