I'm trying to use QStateMachine with QWebPage and I'm stuck in the middle of nowhere.

I'm using qwebpage to load and navigate through a site. During this navigation I have to make a series of actions like connect, login, query, logout, login, query, query, logout, disconnect. So I have my class Session modeling this with abstract methods login, query, logout etc. I also created a state machine inside this class using QStateMachine class. Loading each page is signaled by emitting loadFinished(bool) signal by qwebpage. I have to make sure the next action is not taken until after the previous page is loaded (what means waiting for loadFinished(bool) signal).

What should I do inside loadFinished(bool) and in my methods so that they make use of a state machine to control what actions are made in what moments?