[Qt-interest] How to change QState when clicking a QListView

François KUBLER francois at kubler.org
Fri Aug 6 14:34:13 CEST 2010


Hi list,

This was originally posted in a long mail. As André said, it's much more
smarter to seperate each topic.
So, here we go...

Just to makes things easier, I'm writing a small app with PyQt4 that looks
like this : http://francois.kubler.org/images/projets/z3nb0x_movies.png
Fact that I'm using PyQt4 shouldn't be a problem, any help will be
appreciated :)

My problem is related to QState and SIGNAL/SLOT :

As you can see on the screenshot, I have a QListView. This screen
corresponds to a QState that I called 'listState'. I have another state
which is called 'playerState' where the screen is a video player. The
problem I have is to switch from the 'listState' to the 'playerState' when
I click on a list item.

The important fact in this transition is that the playerState needs to
know what item has been clicked.
I played around with the QAbstractView::clicked ( const QModelIndex &
index ) signal and it works quite well.

My problem is that I can :

- add a transition to the 'playerState' using the QState::addTransition (
QObject * sender, const char * signal, QAbstractState * target ) method
with the clicked signal,

- OR retrieve the QModelIndex representing the clicked item using a basic
SIGNAL/SLOT connection.

But I'd need both (retrieve the clicked item + go to the targeted state).

I tried several things to do that without success (I can describe them if
you want, or even post code).

Is there a way to do that ? What am I missing ?

Thanks a lot for your help,

-- 
François




More information about the Qt-interest-old mailing list