Reputation: 14161
I created a small window using PyQt4 and Pydev. The code is below:
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
# Create GUI object
app = QtGui.QApplication(sys.argv)
widget = QtGui.QWidget()
widget.setGeometry(400,300,800,800) # Position window
widget.resize(450,250) # Resize window
widget.setWindowTitle('Sample') # Set Title of the window
Password = QtGui.QLineEdit() # Input Box for password
widget.show() # Display window
# Exit program
sys.exit(app.exec_())
I created the Password LineEdit box but how to show on the active window, which is represented by widget?
Upvotes: 0
Views: 2455
Reputation: 99317
Just use
Password = QtGui.QLineEdit(widget)
This tells Qt that you want widget
to be the parent of the QLineEdit
. If you leave out the widget
, then the QLineEdit
has no parent, so it's not shown.
Update: To position child items in parent windows, you'll have to read up about layouts (I assume you want to do it properly, not as a toy/learning exercise). Any good PyQt book should be able to help, e.g. this one.
Upvotes: 1