PDA

View Full Version : Using QMainWindow change default position of toolbar. PYQT4



blanka
14th November 2010, 19:25
Hello guys.
I was wondering if anyone can help me with some syntax/expression. i am using QMainWindow

The GUI i am working on has a tool bar , now i want to change the default position of it to the left of the CenterWidget. i am having problem saying put the toolbar to the left ..
http://img833.imageshack.us/img833/2669/picsq.png

Here is the code i have at the moment

toolbar = self.addToolBar('toolbar')
toolbar.addAction(NewDoc)
toolbar.addAction(Map)
toolbar.addAction(Change)
toolbar.addAction(exit)

Here things i tried without luck.



toolbar = self.addToolBar(Qt.LeftToolBarArea)
toolbar.addAction(NewDoc)
toolbar.addAction(Map)
toolbar.addAction(Change)
toolbar.addAction(exit)



toolbar = self.addToolBar('toolabr')
toolbar.LeftToolbarArea()
toolbar.addAction(NewDoc)
toolbar.addAction(Map)
toolbar.addAction(Change)
toolbar.addAction(exit)




toolbar = self.addToolBar(Qt.BottomToolBarArea,'Toolbar')
toolbar.LeftToolbarArea()
toolbar.addAction(NewDoc)
toolbar.addAction(Map)
toolbar.addAction(Change)
toolbar.addAction(exit)

i would appreciate any help. Thank you
ps: sorry for the indent..

blanka
15th November 2010, 17:43
31 views and people have no idea? any python people in this forum?

mushu
7th September 2011, 17:34
check http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qmainwindow.html

you are looking for:
addToolBar (self, Qt.ToolBarArea area, QToolBar toolbar)

What you are doing is storing the result of adding a toolbar to your MainWindow as a variable named toolbar.
You need to first create the toolbar and only then add it to the main window with a position.

example:


from PyQt4.QtGui import *

class MainWindow(QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)

myToolbar = QToolBar()
self.addToolBar( Qt.LeftToolBarArea , myToolbar )