Results 1 to 7 of 7

Thread: Open a window inside another window

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Open a window inside another window

    I tried this by this way: (I'm using PyQt4)

    - I generated a MainWindow using Qt Design with a widget object where I want to load another widget

    - I generated a Widget using Qt Design with a simple button

    Like this:

    #class widget that I want to be loaded
    Qt Code:
    1. class a(object):
    2. def setupUi(self, Form):
    3. Form.setObjectName("Form")
    4. self.btModificar = QtGui.QPushButton(self.centralwidget)
    5. self.btModificar.setGeometry(QtCore.QRect(280, 40, 91, 21))
    6. self.toolBox.setCurrentIndex(0)
    To copy to clipboard, switch view to plain text mode 


    #class that I want to load the widget
    Qt Code:
    1. class Ui_MainWindow(object):
    2. def setupUi(self, MainWindow):
    3. MainWindow.setObjectName("MainWindow")
    4. self.centralwidget = QtGui.QWidget(MainWindow)
    5. self.centralwidget.setObjectName("centralwidget")
    6. self.btAdicionar = QtGui.QPushButton(self.centralwidget)
    7. self.btAdicionar.setGeometry(QtCore.QRect(90, 40, 91, 21))
    8. self.btAdicionar.setObjectName("btAdicionar")
    9. self.widget = QtGui.QWidget(self.centralwidget)
    10. self.widget.setGeometry(QtCore.QRect(160, 105, 811, 471))
    11. self.widget.setObjectName("widget")
    12. MainWindow.setCentralWidget(self.centralwidget)
    13. QtCore.QObject.connect(self.btAdicionar, QtCore.SIGNAL("clicked()"), MainWindow.adicionar)
    To copy to clipboard, switch view to plain text mode 


    # thats the class that implements the Ui_MainWindow
    Qt Code:
    1. class MainWindow (QMainWindow, Ui_MainWindow):
    2.  
    3. def __init__(self, parent=None):
    4. super(MainWindow, self).__init__(parent)
    5. self.setupUi(self)
    6.  
    7. def adicionar(self):
    8. # here I want to load that widget named a
    9. # I tried this:
    10. # aa = a()
    11. # self.widget.setParent(aa)
    12. # self.widget.show()
    13. # but it didnt work
    To copy to clipboard, switch view to plain text mode 
    Last edited by passerb; 18th October 2009 at 01:11.

Similar Threads

  1. open a video file in a new window...
    By jiapei100 in forum Qt Programming
    Replies: 0
    Last Post: 19th September 2009, 14:53
  2. Replies: 2
    Last Post: 9th August 2009, 22:08
  3. Best way to open a Qt window from web page?
    By montylee in forum Qt Programming
    Replies: 9
    Last Post: 19th January 2009, 08:04
  4. Storing window geometry inside XML file.
    By GuS in forum Qt Programming
    Replies: 4
    Last Post: 17th July 2008, 13:42
  5. right way to open a new window
    By wind in forum Newbie
    Replies: 1
    Last Post: 1st November 2006, 11:17

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
  •  
Qt is a trademark of The Qt Company.