Results 1 to 7 of 7

Thread: No spontaneous showEvent generated when window is opened ?!

  1. #1
    Join Date
    Oct 2010
    Posts
    4
    Qt products
    Qt4

    Question No spontaneous showEvent generated when window is opened ?!

    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:

    Qt Code:
    1. void MainWindow::showEvent(QShowEvent *event){
    2. if(event->spontaneous()){
    3. qDebug()<<"after";
    4. } else qDebug()<<"before";
    5. }
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Oct 2010
    Posts
    4
    Qt products
    Qt4

    Default Re: No spontaneous showEvent generated when window is opened ?!

    Bump! No ideas?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: No spontaneous showEvent generated when window is opened ?!

    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Oct 2010
    Posts
    4
    Qt products
    Qt4

    Default Re: No spontaneous showEvent generated when window is opened ?!

    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.

  5. #5
    Join Date
    May 2010
    Posts
    7
    Qt products
    Qt4

    Default Re: No spontaneous showEvent generated when window is opened ?!

    Try re-implementing resizeEvent instead.

  6. #6
    Join Date
    Oct 2010
    Posts
    4
    Qt products
    Qt4

    Default Re: No spontaneous showEvent generated when window is opened ?!

    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.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: No spontaneous showEvent generated when window is opened ?!

    Quote Originally Posted by yesint View Post
    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. ow to remove spontaneous events from application?
    By barrygp in forum Qt Programming
    Replies: 2
    Last Post: 7th October 2010, 03:23
  2. How to override ShowEvent() etc
    By marcvanriet in forum Newbie
    Replies: 1
    Last Post: 22nd September 2010, 10:13
  3. Replies: 9
    Last Post: 16th May 2010, 16:21
  4. spontaneous events
    By onamatic in forum Qt Programming
    Replies: 2
    Last Post: 4th February 2010, 08:29
  5. Close Dialog in showEvent
    By pospiech in forum Qt Programming
    Replies: 3
    Last Post: 11th April 2008, 15:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.