Results 1 to 12 of 12

Thread: how to change the position of menu of QMainWindow

  1. #1
    Join Date
    May 2008
    Posts
    58
    Thanks
    2

    Default how to change the position of menu of QMainWindow

    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!

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to change the position of menu of QMainWindow

    menuBar() returns QMenuBar , not QMenu.

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

  3. #3
    Join Date
    May 2008
    Posts
    58
    Thanks
    2

    Default Re: how to change the position of menu of QMainWindow

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to change the position of menu of QMainWindow

    You'd have to remove it from the main window's layout and handle the geometry yourself all the time. What is your usecase?

  5. #5
    Join Date
    May 2008
    Posts
    58
    Thanks
    2

    Default Re: how to change the position of menu of QMainWindow

    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?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to change the position of menu of QMainWindow

    Did you try using style sheets for that? You should be able to declare alignment of menu bar items this way.

  7. #7
    Join Date
    Apr 2008
    Posts
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to change the position of menu of QMainWindow

    Quote Originally Posted by yxmaomao View Post
    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?

  8. #8
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to change the position of menu of QMainWindow

    Why dont you use QToolBar ??? u can have a more combinations of using QWidget with toolbar....

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to change the position of menu of QMainWindow

    As a follow-up of my previous post, seems that using the following stylesheet works very nice:
    css Code:
    1. QMenuBar::item { padding-top: 120px; }
    To copy to clipboard, switch view to plain text mode 

  10. #10
    Join Date
    May 2008
    Posts
    58
    Thanks
    2

    Default Re: how to change the position of menu of QMainWindow

    Hi wysota

    Could you tell me how to use stylesheet in detailed

    Thanks

  11. #11
    Join Date
    May 2008
    Posts
    58
    Thanks
    2

    Default Re: how to change the position of menu of QMainWindow

    Hi wysota

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

  12. #12
    Join Date
    Sep 2016
    Posts
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: how to change the position of menu of QMainWindow

    hello,i have the same question as you ,can you tell me how to do it? thank you !!

Similar Threads

  1. QGraphicsTextItem: handling cursor position change
    By Angelo Moriconi in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2007, 11:42
  2. How to get a position of the menu bar item?
    By Mad Max in forum Qt Programming
    Replies: 2
    Last Post: 20th November 2006, 04:20
  3. How to change system menu of window?
    By krivenok in forum Qt Programming
    Replies: 1
    Last Post: 27th January 2006, 16:19
  4. how change the QListBox item position by pixel
    By roy_skyx in forum Qt Programming
    Replies: 2
    Last Post: 20th January 2006, 02:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.