Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMenuBar corner widget not aligned to right edge
Forum Updated to NodeBB v4.3 + New Features

QMenuBar corner widget not aligned to right edge

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Taytoo
    wrote on last edited by Taytoo
    #1

    Trying to add a button as corner widget. In Qt Designer I created the menubar and button (but its not assigned to layout etc). Then in constructor, I'm calling

    ui.menu->setCornerWidget(ui.cornerbutton);
    
    

    but there is always some spacing on the right side of button, how do I adjust the margin/spacing on right?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Taytoo
      wrote on last edited by
      #4

      Figured out the problem. Essentially what's happening is that Qt is going by some minimum width (~200px). Since I was setting button width around 50px, the remaining space was showing up as margin/spacing between button and edge.

      Solution is to either increase the width of the button or add it to a layout inside another widget, and set that widget as corner widget, so even if Qt resizes the widget to a larger size, the button inside can still remain the desired width.

      1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        Based on the method documentation the widget is out right after the rightmost item in the menu bar so it's likely what you see.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        T 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Based on the method documentation the widget is out right after the rightmost item in the menu bar so it's likely what you see.

          T Offline
          T Offline
          Taytoo
          wrote on last edited by
          #3

          @SGaist The menubar has 4 items and when window opens its maximized, so there is a lot of space between last menubar item and corner widget/button. Its weird that it isnt positioned to right edge.

          This guy seems to be having the same issue: https://stackoverflow.com/questions/48361829/remove-offset-of-cornerwidget-in-qmenubar

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Taytoo
            wrote on last edited by
            #4

            Figured out the problem. Essentially what's happening is that Qt is going by some minimum width (~200px). Since I was setting button width around 50px, the remaining space was showing up as margin/spacing between button and edge.

            Solution is to either increase the width of the button or add it to a layout inside another widget, and set that widget as corner widget, so even if Qt resizes the widget to a larger size, the button inside can still remain the desired width.

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved