Results 1 to 2 of 2

Thread: Show new window on button click

  1. #1
    Join Date
    Oct 2010
    Posts
    4
    Qt products
    Platforms
    Windows

    Default Show new window on button click

    How can i show a new window on button click of main window?

    i tried this code in PyQt: (me doing in PyQt)

    inside python class:

    QtCore.QObject.connect(win.btnShow, QtCore.SIGNAL(_fromUtf8("clicked()")), self.showWin)

    Then function,

    def showWin(self):

    app2 = QtGui.QApplication(sys.argv)
    clsObj2 = AddShot.Ui_MainWindow()
    win2 = QtGui.QMainWindow()
    clsObj2.setupUi(win2)
    win2.show()
    app2.exec_()


    No errors. But the window shows as a flash and goes!
    Why this happens?

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Show new window on button click

    1. Use code tags to improve readability.
    2. Don't create a second QApplication. 1 is enough and all you need.
    3. You should probably not create a second main window. Create a dialog instead.
    4. Don't start a new event loop. It will lead to trouble.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. Replies: 0
    Last Post: 10th September 2010, 13:23
  2. Right-Click menu on a pushButton doesn't show up
    By qtpyqt in forum Qt Programming
    Replies: 6
    Last Post: 9th September 2010, 17:58
  3. How can I know which button click.
    By electronicboy in forum Qt Programming
    Replies: 10
    Last Post: 4th October 2009, 14:27
  4. button click in webview
    By mind_freak in forum Qt Programming
    Replies: 1
    Last Post: 29th September 2009, 13:48
  5. QPaintEvent on button click?
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 5th June 2007, 08:44

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.