| The Following User Says Thank You to Rob1n For This Useful Post: | ||
|
|
2010-06-11
, 15:06
|
|
|
Posts: 1,296 |
Thanked: 1,773 times |
Joined on Aug 2009
@ Budapest, Hungary
|
#12
|
|
|
2010-06-11
, 15:31
|
|
|
Posts: 2,121 |
Thanked: 1,540 times |
Joined on Mar 2008
@ Oxford, UK
|
#13
|
|
|
2010-06-11
, 15:35
|
|
Posts: 3,428 |
Thanked: 2,856 times |
Joined on Jul 2008
|
#14
|
!#I don't use PySide
from PyQt4 import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
class MyMainWindow(QWidget):
def __init__(self):
QWidget.__init__(self, None)
vbox = QVBoxLayout()
b = QPushButton("Push me!")
vbox.addWidget(b)
self.connect(b, SIGNAL("clicked()"), self.buttonPushed)
self.setLayout(vbox)
def buttonPushed(self):
d = QDialog(self)
vbox = QVBoxLayout()
#Add Layouts
horizontalLayout = QHBoxLayout()
horizontalLayout1 = QHBoxLayout()
# Now create your buttons.
b = QPushButton("Close window")
c = QPushButton("Die")
e = QPushButton("In Fires")
f = QPushButton("With Chickens!")
self.connect(b, SIGNAL("clicked()"), d.close)
# Add buttons to your layouts, they'll show up in the order given.
horizontalLayout1.addWidget(f)
horizontalLayout1.addWidget(b)
horizontalLayout.addWidget(c)
horizontalLayout.addWidget(e)
# Add layouts to your main Layout
vbox.addLayout (horizontalLayout)
vbox.addLayout (horizontalLayout1)
d.setLayout(vbox)
# Show the window!
d.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
w = MyMainWindow()
w.show()
app.exec_()
sys.exit()
|
|
2010-06-11
, 20:43
|
|
Posts: 341 |
Thanked: 57 times |
Joined on Nov 2009
|
#15
|

|
|
2010-06-11
, 20:51
|
|
Posts: 402 |
Thanked: 229 times |
Joined on Nov 2009
@ Missouri, USA
|
#16
|
Alright thanks everyone for your support .. working like a charm now
One more question, how can I make the QDialog pop out from the sides, instead of from the bottom in an upward direction ?
self.setAttribute(Qt.WA_Maemo5PortraitOrientation)
|
|
2010-06-11
, 21:02
|
|
Posts: 341 |
Thanked: 57 times |
Joined on Nov 2009
|
#17
|
If it has no parent, you can just set the orientation attribute:
If it belongs to another widget (has a parent), you will set this attribute on its parent.Code:self.setAttribute(Qt.WA_Maemo5PortraitOrientation)
For more examples of orientation, how to use forms created with Qt Designer, or anything else, check out the source of maegym
Code is fairly clean, though I plan to refactor a few things.

|
|
2010-06-11
, 21:38
|
|
Posts: 402 |
Thanked: 229 times |
Joined on Nov 2009
@ Missouri, USA
|
#18
|
|
|
2010-06-11
, 22:57
|
|
Posts: 341 |
Thanked: 57 times |
Joined on Nov 2009
|
#19
|
|
|
2010-06-12
, 06:22
|
|
Posts: 341 |
Thanked: 57 times |
Joined on Nov 2009
|
#20
|
I'd suggest reading the documentation on this - http://doc.qt.nokia.com/qt-maemo-4.6...d-layouts.html and http://doc.qt.nokia.com/qt-maemo-4.6/layout.html should cover how widgets and layouts interact (a QDialog is really just another widget).