PDA

View Full Version : how to change the position of menu of QMainWindow



yxmaomao
21st May 2008, 02:48
Hi Guys

I need your help

I am developing an application which need adjust default menu's position

my mainwindow inherits from QMainWindow

I try the below, but it doesn't work:

QMenu * myMenu = menuBar();
myMenu->move(x,y);

Who can help me?
Thanks in advance!

aamer4yu
21st May 2008, 08:27
menuBar() returns QMenuBar , not QMenu.

Also wat do u mean by moving menu ?? didnt understand that :(

yxmaomao
21st May 2008, 08:57
My Question is:

You know default , menu bar will be displayed at the top-left of main window, for example now I want it to be showed at down to 120 pix, just like below:

____________________
| default menu here
|
| now I want to show here

wysota
21st May 2008, 09:24
You'd have to remove it from the main window's layout and handle the geometry yourself all the time. What is your usecase?

yxmaomao
21st May 2008, 09:40
my usecase as below:

------------------------------------------------------------------------------------
menu here My Logo zoom control
-------------------------------------------------------------------------------------
| |
| |
| |
| Center Widget |
| |
-------------------------------------------------------------------------------------
now problem is My Logo is larger than menu's height, so I want to adjust menu text
align with the bottom of my logo picture.

Do I say clearly?

wysota
21st May 2008, 09:44
Did you try using style sheets for that? You should be able to declare alignment of menu bar items this way.

fifth
21st May 2008, 14:22
my usecase as below:

------------------------------------------------------------------------------------
menu here My Logo zoom control
-------------------------------------------------------------------------------------
| |
| |
| |
| Center Widget |
| |
-------------------------------------------------------------------------------------
now problem is My Logo is larger than menu's height, so I want to adjust menu text
align with the bottom of my logo picture.

Do I say clearly?

Would it not be easier just to put your logo underneath the menu?

aamer4yu
21st May 2008, 14:47
Why dont you use QToolBar ??? u can have a more combinations of using QWidget with toolbar....

wysota
21st May 2008, 21:28
As a follow-up of my previous post, seems that using the following stylesheet works very nice:
QMenuBar::item { padding-top: 120px; }

yxmaomao
22nd May 2008, 01:15
Hi wysota

Could you tell me how to use stylesheet in detailed

Thanks

yxmaomao
22nd May 2008, 01:30
Hi wysota

Thanks wysota again
I have done it, it works very well

ln1990
17th September 2016, 17:12
hello,i have the same question as you ,can you tell me how to do it? thank you !!