Results 1 to 7 of 7

Thread: launching animated window from already open window

  1. #1
    Join Date
    Nov 2012
    Posts
    35
    Thanks
    1
    Thanked 7 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default launching animated window from already open window

    I managed to animate open a window on startup, but I want to open a different window from already open window by pressing the button, in my case already open window is open in fullscreen mode with window.raise_()

    Not sure but is this why the window I am trying to animate open by pressing a button is not opening
    Qt Code:
    1. from PyQt4 import QtCore,QtGui
    2.  
    3. import sys
    4.  
    5. class WindLauncher(QtGui.QMainWindow):
    6. """ docstring for WindLauncher
    7. """
    8. def __init__(self):
    9. super(WindLauncher, self).__init__()
    10. self.btn = QtGui.QPushButton("Launch")
    11. self.btn.clicked.connect(self.launchWin)
    12. self.setCentralWidget(self.btn)
    13.  
    14.  
    15. def launchWin(self):
    16. main = MyTableView()
    17. sw = QtGui.QDesktopWidget().screenGeometry(main).width()
    18. sh = QtGui.QDesktopWidget().screenGeometry(main).height()
    19. animation = QtCore.QPropertyAnimation(main, "geometry")
    20. animation.setDuration(500);
    21. animation.setStartValue(QtCore.QRect(0, -(sh), sw, sh));
    22. animation.setEndValue(QtCore.QRect(0, 0, sw, sh));
    23. animation.start();
    24. self.show()
    25. self.raise_()
    26.  
    27. class MyTableView(QtGui.QTableView):
    28. """docstring for MyTableView"""
    29. def __init__(self, parent=None):
    30. super(MyTableView, self).__init__(parent)
    31.  
    32.  
    33. if __name__ == "__main__":
    34. application = QtGui.QApplication(sys.argv)
    35. main = WindLauncher()
    36. main.show()
    37. main.raise_()
    38. sys.exit(application.exec_())
    To copy to clipboard, switch view to plain text mode 
    Last edited by krystosan; 11th December 2013 at 18:38.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: launching animated window from already open window

    What are the values of sw and sh at lines 17 and 18? What screen is an unshown widget on?

  3. #3
    Join Date
    Nov 2012
    Posts
    35
    Thanks
    1
    Thanked 7 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: launching animated window from already open window

    Quote Originally Posted by ChrisW67 View Post
    What are the values of sw and sh at lines 17 and 18? What screen is an unshown widget on?
    Looking at that I updated my code but still it seems doesn't work, I just see a flickr

    Qt Code:
    1. from PyQt4 import QtCore,QtGui
    2. from functools import partial
    3. import sys
    4.  
    5. class MyTableView(QtGui.QTableView):
    6. """docstring for MyTableView"""
    7. def __init__(self, parent=None):
    8. super(MyTableView, self).__init__(parent)
    9. self.showFullScreen()
    10. sw = QtGui.QDesktopWidget().screenGeometry(self).width()
    11. sh = QtGui.QDesktopWidget().screenGeometry(self).height()
    12. self.setGeometry(QtCore.QRect(0, -(sh), sw, sh))
    13.  
    14. class WindLauncher(QtGui.QMainWindow):
    15. """ docstring for WindLauncher
    16. """
    17. def __init__(self):
    18. super(WindLauncher, self).__init__()
    19. self.btn = QtGui.QPushButton("Launch")
    20. sw = QtGui.QDesktopWidget().screenGeometry(self).width()
    21. sh = QtGui.QDesktopWidget().screenGeometry(self).height()
    22. callLaunch = partial(self.launchWin, sw, sh)
    23. self.btn.clicked.connect(callLaunch)
    24. self.setCentralWidget(self.btn)
    25.  
    26. def launchWin(self, sw, sh):
    27. main = MyTableView()
    28. animation = QtCore.QPropertyAnimation(main, "geometry")
    29. animation.setDuration(500);
    30. animation.setStartValue(QtCore.QRect(0, -(sh), sw, sh));
    31. animation.setEndValue(QtCore.QRect(0, 0, sw, sh));
    32. animation.start();
    33. main.show()
    34. main.raise_()
    35.  
    36. if __name__ == "__main__":
    37. application = QtGui.QApplication(sys.argv)
    38. main = WindLauncher()
    39. main.show()
    40. main.raise_()
    41. sys.exit(application.exec_())
    To copy to clipboard, switch view to plain text mode 
    Last edited by krystosan; 12th December 2013 at 15:06.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: launching animated window from already open window

    I am not a Python programmer but I expect that the local variable "main" in goes out of scope at the end of the function taking the table widget with it. Same for the "animation" object. Try "self.main" and "self.animation"

  5. #5
    Join Date
    Nov 2012
    Posts
    35
    Thanks
    1
    Thanked 7 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: launching animated window from already open window

    yes, thats it. thanks. however why does the window that has button stays on top , when i have self.main.raise_() for new animating window ?

  6. The following user says thank you to krystosan for this useful post:


  7. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: launching animated window from already open window

    Take a look at QWidget::activateWindow() and the notes about Windows

  8. #7
    Join Date
    Nov 2012
    Posts
    35
    Thanks
    1
    Thanked 7 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: launching animated window from already open window

    I have got things working but animation doesn't seems to be smooth, is it because the new window is accessing the same QAbstractListModel or something else I need to add to QPropertyAnimation ?

Similar Threads

  1. Replies: 2
    Last Post: 14th January 2013, 07:07
  2. Replies: 3
    Last Post: 23rd December 2010, 06:55
  3. Replies: 2
    Last Post: 17th September 2010, 11:44
  4. Replies: 0
    Last Post: 10th September 2010, 13:23
  5. Open a window inside another window
    By passerb in forum Qt Programming
    Replies: 6
    Last Post: 18th October 2009, 13:24

Tags for this Thread

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.