Subclassed qlistwidget event handling problem
Re: Subclassed qlistwidget event handling problem
Quote:
Originally Posted by
Annihilator
Handlers for mouseMoveEvent, keyPressEvent and paintEvent work but for itemPressed, currentRowChanged, currentItemChanged do not. What`s the problem?
It's because they are signals and not event handlers! Use QObject::connect() to connect them to a local slot.
Re: Subclassed qlistwidget event handling problem
I`ve made
defined slot in header file of mywidget
but still does not work
Re: Subclassed qlistwidget event handling problem
where is the connect statement and please can you show us your full header file. Have you also recompiled your project, used the Q_OBJECT makro...
Your syntax is fine, so it normally should work.
Re: Subclassed qlistwidget event handling problem
Code:
{
Q_OBJECT
public:
explicit CustomListWidget
(QWidget *parent
= 0);
signals:
//void currentItemChanged ( QListWidgetItem * current, QListWidgetItem * previous );
//void itemPressed ( QListWidgetItem * item );
public slots:
public:
int currentItemIndex;
protected:
};
I`ve tried to make connection in CustomListWidget constructor (my last post)
Also I`ve tried in MainWindow constructore like
Code:
MainWindow
::MainWindow(QWidget *parent
) :ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
but nothing happened. I always rebuild my project.
p.s.
here is my slot
Re: Subclassed qlistwidget event handling problem
Hi,
make the connection in the c-tor of your CustomListWidget. And what exactly is not working for you? try
Code:
{
qWarning() << "slot reached: itemPressed_s";
}
Did you see the output?
And as a note: in your mainwindow it has to be:
Re: Subclassed qlistwidget event handling problem
You dont have to mention the type name in signal and slot,,,only the type.
This
should be -
Try and see if it works :)
Re: Subclassed qlistwidget event handling problem
@aamer4u: Damn, you are right! need to go to an optician;)
Re: Subclassed qlistwidget event handling problem
Ooops. that's it! Thanks, aamer4yu!
Re: Subclassed qlistwidget event handling problem
@Lykurg... it happens sometimes to me too....the tiniest details are skipped by mind ,, u are not alone !!
@Annhilator.. welcome :-)