Results 1 to 2 of 2

Thread: QStatusBar height

  1. #1
    Join Date
    Apr 2013
    Posts
    14
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default QStatusBar height

    Hi,

    I have a small issue with QStatusBar. It seems to have a bit bigger height than it is supposed to:
    Capture.PNG
    Here's the code that creates it:
    Qt Code:
    1. QToolButton *abt = new QToolButton(this);
    2. abt->setDefaultAction(aboutAction);
    3.  
    4. QLabel *gridSpacingLabel = new QLabel(tr(" Grid Spacing: 20"));
    5. QLabel *xPosLabel = new QLabel(tr(" X: 640 "));
    6. QLabel *yPosLabel = new QLabel(tr(" Y: 640 "));
    7. QLabel *widthLabel = new QLabel(tr(" Width: 640 "));
    8. QLabel *heightLabel = new QLabel(tr(" Height: 480 "));
    9. QLabel *unsavedDataLabel = new QLabel();
    10. QPixmap pixmap(":changes.png");
    11. unsavedDataLabel->setPixmap(pixmap);
    12.  
    13. statusBar()->addPermanentWidget(abt);
    14. statusBar()->addPermanentWidget(gridSpacingLabel);
    15. statusBar()->addPermanentWidget(xPosLabel);
    16. statusBar()->addPermanentWidget(yPosLabel);
    17. statusBar()->addPermanentWidget(widthLabel);
    18. statusBar()->addPermanentWidget(heightLabel);
    19. statusBar()->addPermanentWidget(unsavedDataLabel);
    To copy to clipboard, switch view to plain text mode 

    I tried the following (separately) and other sizePolicy combinations but none seem to remove that strip at the top.
    Qt Code:
    1. statusBar()->setMaximumHeight(20);
    2. statusBar()->layout()->setContentsMargins(0,0,0,0);
    3. statusBar()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
    To copy to clipboard, switch view to plain text mode 

    I am looking for something like this (from Notepad++):
    Capture2.PNG

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QStatusBar height

    That strip at the top is probably the bottom of the frame around your main window's central widget. (QScrollArea, maybe?) My app, which uses a QTabWidget as the central widget, does not have this extra space on the status bar. The other major difference between your status bar and mine is that you place a pixmap on it, but that shouldn't cause what you see.

  3. The following user says thank you to d_stranz for this useful post:

    regular (21st October 2014)

Similar Threads

  1. QStatusBar Resizes
    By KineticArc in forum Qt Programming
    Replies: 0
    Last Post: 17th February 2011, 17:38
  2. Why QStatusBar do not at the bottom?
    By FinderCheng in forum Qt Programming
    Replies: 5
    Last Post: 29th September 2009, 08:26
  3. QStatusBar
    By newermind in forum Qt Programming
    Replies: 3
    Last Post: 1st June 2009, 21:48
  4. Embedding QProgressBar in QStatusBar: Height issues
    By elahav in forum Qt Programming
    Replies: 3
    Last Post: 11th February 2009, 14:39
  5. about QStatusBar
    By Pang in forum Qt Programming
    Replies: 1
    Last Post: 16th November 2006, 04:15

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.