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. Width of QStatusBar

Width of QStatusBar

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 2.9k Views 1 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.
  • A Offline
    A Offline
    Ailurus
    wrote on last edited by Ailurus
    #1

    I'm wondering how to change the width of my QStatusBar such that it has the same width as my QMainWindow (which contains a Horizontal Layout using certain margins, might be relevant to mention this).

    Part of the code:

    statusBar();
    
    GeneralInfo = new QLabel("[General Info]");
    GeneralInfo->setAlignment(Qt::AlignCenter);
    statusBar()->addPermanentWidget(GeneralInfo, 1);
    MeshInfo = new QLabel("");
    MeshInfo->setAlignment(Qt::AlignCenter);
    statusBar()->addPermanentWidget(MeshInfo, 1);
    
    statusBar()->setStyleSheet(QString("margin-right: 0px; padding: 6px;"));
    

    Result (at runtime):

    I get similar results when leaving out the last line of code (using the style sheet). When maximizing the window, the width of the QStatusBar is correct (with or without the code shown above).

    One other attempt to solve the issue:

    statusBar()->setMinimumWidth(width());
    

    Here, width() returns the width of my QMainWindow. No luck though. Any ideas?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      The corner space is occupied by a resize handle. It's not visible in your theme but you can use this stylesheet to see it clearly:

      statusBar()->setStyleSheet("margin-right: 0px; padding: 6px; border: 1px solid red;");
      

      Maximized window has no resize handle so that's why the issue goes away.
      If you don't want the resize handle you can disable it with statusBar()->setSizeGripEnabled(false);.

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Ailurus
        wrote on last edited by
        #3

        Thanks! Problem solved :).

        1 Reply Last reply
        0

        • Login

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