PDA

View Full Version : No spontaneous showEvent generated when window is opened ?!



yesint
2nd November 2010, 14:39
Dear all,
I'm trying to scroll very large list to specific position when main window is opened. As far as I understand for this I need to add code to spontaneous showEvent because this is one executed just after window is opened.
Here is the code:



void MainWindow::showEvent(QShowEvent *event){
if(event->spontaneous()){
qDebug()<<"after";
} else qDebug()<<"before";
}


This always prints "before" - there is no spontaneous event at all! It seems that i missed something simple. Any help is deeply appreciated!

yesint
6th November 2010, 17:01
Bump! No ideas?

wysota
7th November 2010, 12:37
I doubt show events are ever spontaneous. Show events are generated within your application. Maybe when application is being unminimized a spontaneous show event might occur. Why do you need to react on spontaneous events only?

yesint
8th November 2010, 20:28
Well, what I need to do is to scroll a very long list just upon creation of the window. The scrollTo method only works when the window is already shown, so I don't see any other way to do this. If there is some, please give me a hint.

yakuzan
8th November 2010, 21:51
Try re-implementing resizeEvent instead.

yesint
9th November 2010, 08:03
No luck. resizeEvent is either not called when the window is shown for the first time or called before showEvent. Anyway scrollTo doesn't work. I'll probably make a new thread for scrollTo functionality.

wysota
9th November 2010, 09:58
Well, what I need to do is to scroll a very long list just upon creation of the window. The scrollTo method only works when the window is already shown, so I don't see any other way to do this. If there is some, please give me a hint.

But why are you checking if the event is spontaneous?