Reply
Thread Tools
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#11
Originally Posted by ahmadka View Post
Forgive me, I'm such a n00b at this right now .. I tried using QDialog as well, but I couldn't figure out what method does it have to add buttons and stuff to it .. With QDialogButtonBox, there's an addButton method which can be used to add buttons to QDialogButtonBox ... How do I add controls to a QDialog ... ?
You generally don't directly. You'll want to create a layout (or a set of nested layouts) to... erm... layout... the design of your dialogue. You then use addWidget (and addLayout) to build them up. Finally you can use setLayout to add the top-level layout to your dialog.

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).
 

The Following User Says Thank You to Rob1n For This Useful Post:
Venemo's Avatar
Posts: 1,296 | Thanked: 1,773 times | Joined on Aug 2009 @ Budapest, Hungary
#12
Hey,

Rob1n said all the good things and stuff, I just would like to add one more tip:

Basically, all of these classes have great static methods that should ease your life.
 
pelago's Avatar
Posts: 2,121 | Thanked: 1,540 times | Joined on Mar 2008 @ Oxford, UK
#13
You might want to look into getting a book about Qt such as one of those listed at http://qt.nokia.com/developer/books/ (can anyone make some specific recommendations?)
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#14
Quick example, basically ripped it from here and modified it to do what you're asking (simplistically, you'll still need to figure out formatting). I only left comments in the areas that I changed since you can read his original tutorial/comments at the website.

Developed, screenshotted, and uploaded to a webserver all on my N900. I love this "phone" !

Code:
#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()
Attached Images
 
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 

The Following 3 Users Say Thank You to fatalsaint For This Useful Post:
Posts: 341 | Thanked: 57 times | Joined on Nov 2009
#15
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 ?
 
Posts: 402 | Thanked: 229 times | Joined on Nov 2009 @ Missouri, USA
#16
Originally Posted by ahmadka View Post
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 ?
Set the orientation attribute:
Code:
self.setAttribute(Qt.WA_Maemo5PortraitOrientation)
You will do this on the dialog's parent widget usually. Though it's possible to do this on the dialog itself, its weird to do so. It will change the orientation of the window, then once the dialog is closed, it will go back to its original orientation.

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.
__________________
aspidites | blog | aspidites@inbox.com

Last edited by aspidites; 2010-06-11 at 20:59.
 
Posts: 341 | Thanked: 57 times | Joined on Nov 2009
#17
Originally Posted by aspidites View Post
If it has no parent, you can just set the orientation attribute:
Code:
self.setAttribute(Qt.WA_Maemo5PortraitOrientation)
If it belongs to another widget (has a parent), you will set this attribute on its parent.

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.
errr ... I think you misunderstood me .. I'm not talking about switching to Portrait mode or anything, or that how do I popup the QDialog properly while in portrait mode ...

I'm asking how can I make the QDialog pop out from the left side of the screen (or from the right side of the screen), instead of poping out from the bottom of the screen ?

Here is a picture to show what I mean:



The bottom center arrow with a cross on it depicts the normal bottom --> up poping method .. how can I instead have vertical QDialogs that pop into view from either the left or right side of the screen ? Is this possible ?

Last edited by ahmadka; 2010-06-11 at 21:07.
 
Posts: 402 | Thanked: 229 times | Joined on Nov 2009 @ Missouri, USA
#18
My guess would be subclass QDialog and override the show method and or show event, using a QPropertyAnimation.
__________________
aspidites | blog | aspidites@inbox.com
 
Posts: 341 | Thanked: 57 times | Joined on Nov 2009
#19
Yep, it seems to be more difficult than I thought ... Any code examples for doing such show () method re-implementations with different animations ?
 
Posts: 341 | Thanked: 57 times | Joined on Nov 2009
#20
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 22:00.