![]() |
2010-06-29
, 21:52
|
|
Posts: 1,111 |
Thanked: 1,985 times |
Joined on Aug 2009
@ Åbo, Finland
|
#2
|
Im trying to set the orientation of a simple test Gui to portrait and I thought by adding
self.ui.setAttribute(Qt.WA_Maemo5PortraitOrientati on, True)
to the main.py file that would do it. Unfortunately it doesn't seem to be that simple. Once things go past being dead simple then Im in trouble, could someone more familiar point me to the problem and how I can correct it? Many thanks
Code:#!/usr/bin/python2.5 import sys from PyQt4 import QtGui,QtCore from portraitTest import * class MyForm(QtGui.QMainWindow): def __init__(self, parent=None): #build parent user interface QtGui.QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) try : self.ui.setAttribute(Qt.WA_Maemo5PortraitOrientation, True) except:print("Cannot set orientation to portrait") if __name__ == "__main__": app = QtGui.QApplication(sys.argv) myapp = MyForm() myapp.show() sys.exit(app.exec_())
#!/usr/bin/python2.5 import sys from PyQt4.QtGui import * from PyQt4.QtCore import * # from portraitTest import * class MyForm(QMainWindow): def __init__(self, parent=None): #build parent user interface QWidget.__init__(self, parent) # self.ui = Ui_MainWindow() # self.ui.setupUi(self) try : self.setAttribute(Qt.WA_Maemo5PortraitOrientation, True) except:print("Cannot set orientation to portrait") if __name__ == "__main__": app = QApplication(sys.argv) myapp = MyForm() myapp.show() sys.exit(app.exec_())
![]() |
2010-06-30
, 00:19
|
Posts: 1,086 |
Thanked: 2,964 times |
Joined on Jan 2010
|
#3
|
![]() |
2010-06-30
, 11:54
|
|
Posts: 1,111 |
Thanked: 1,985 times |
Joined on Aug 2009
@ Åbo, Finland
|
#4
|
Thank you for your help Mece
I finally got it working by removing the "ui" from self.ui.setAttribute(Qt.WA_Maemo5PortraitOrientati on, True), so it now reads self.setAttribute.......
One thing that kinda irritates me is that when I minimize the application window, to see the multitasking view, it goes back into trying to display the form in landscape view so it looks wrong in the small preview pane. Once I click on it again, it expands and goes back into portrait. Is this normal behaviour?
The Following User Says Thank You to mece For This Useful Post: | ||
self.ui.setAttribute(Qt.WA_Maemo5PortraitOrientati on, True)
to the main.py file that would do it. Unfortunately it doesn't seem to be that simple. Once things go past being dead simple then Im in trouble, could someone more familiar point me to the problem and how I can correct it? Many thanks
Follow me on my neglected twitter @kojacker
Cybot950 - Control a robot with your N9/N950
SMSPetFeeder - Build a Bluetooth/SMS dog feeder with Qt, N950, and arduino
Nerf950 - Use your N9/N950 to fire a Nerf gun