mossin
March 22, 2011, 6:38am
1
hi all
is there any way to add space in menuBar?
i m using borderless window, and i want to put close button at very right of menubar.
i had done same thing with toolbar, later i added menuBar on window, now i want close button on menuBar (putting it on toolBar doesnt look good)
thanks in advance
regards
mossin
I’m not sure if you can add a QSpacerItem on a menu bar (I guess you just mistyped and meant “space” instead of “spacer”?). However you can adjust the geometry of a menu bar. It’s a bit tricky, so here’s the code:
self.menubar=self.menuBar()
self.menubar.setParent(None)
self.menubar.setParent(self)
self.menubar.setGeometry(…
set up your menu before you call this. This works here on Windows. Mac menu bars behave quite differently. Also I’m not quite sure why I have to set the parent first to None and then to self. Without this it wouldn’t always work.
mossin
March 23, 2011, 6:53am
3
hi robert
thanks for your reply,
i haven’t checked that, i will let you know if it is working or not
thanks and regards
mossin
mossin
March 24, 2011, 12:04am
4
hey robert,
that code is working, but it’s disturbing toolbar alignment, is there any other option to add widget on menubar ?
thanks and regards
mossin
mossin
March 24, 2011, 1:08am
5
hi robert
so by adding extra toolbar did the trick (we can add extra toolbar, i was not aware of it)
instead of adding menubar, i added toolBar at menubar’s position and using
toolbar.addWidget() i called menubar on toolbar
self.toolbar = self.addToolBar(‘toolBar1’)
self.addToolBarBreak(Qt.TopToolBarArea)
self.addToolBar(newTool)
newTool = self.addToolBar(‘toolBar2’)
self.addToolBarBreak(Qt.TopToolBarArea)
self.addToolBar(newTool)
what i wanted, i found by trying this code
thanks and regards
mossin