Results 1 to 7 of 7

Thread: Adding QLabel to QMainWindow statusbar

  1. #1
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Adding QLabel to QMainWindow statusbar

    Hi
    When adding QLabels to a QMainwindow e get this vertical lines separating them?
    How do i remove it?
    statusbarverticalline.png
    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Adding QLabel to QMainWindow statusbar

    One thing you could do is to put all things that should appear together into one widget and then add that widget to the status bar.

    Cheers,
    _

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

    graciano (10th November 2013)

  4. #3
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Adding QLabel to QMainWindow statusbar

    QLabel is already a Widget but anyway e tested it with the same result.
    widgetTest.png

    Must be something else.

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Adding QLabel to QMainWindow statusbar

    Of course a QLabel is a QWidget, but that's not what I wrote.

    But since you claim you have tested my suggestion, can you show the code of how you did it?

    Cheers,
    _

  6. The following user says thank you to anda_skoa for this useful post:

    graciano (10th November 2013)

  7. #5
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Adding QLabel to QMainWindow statusbar


  8. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Adding QLabel to QMainWindow statusbar

    The style puts separators between separate widgets in the status bar. If you do not want separators between your widgets in the status bar then only insert a single widget. You then have complete control over the layout of other widgets within that single widget. This is what anda_skoa suggested above, and you have not done in your code.

    Qt Code:
    1. // You are doing the equivalent of this
    2. QStatusBar *sb = a.statusBar();
    3. sb->addWidget(new QLabel("A"));
    4. sb->addWidget(new QLabel("B"));
    5. sb->addWidget(new QLabel("C"));
    6. a.show();
    7.  
    8. // We are saying do this
    9. QStatusBar *sb = b.statusBar();
    10. QHBoxLayout *layout = new QHBoxLayout;
    11. layout->addWidget(new QLabel("D"));
    12. layout->addWidget(new QLabel("E"));
    13. layout->addWidget(new QLabel("F"));
    14. layout->setContentsMargins(0,0,0,0);
    15. QWidget *container = new QWidget;
    16. container->setLayout(layout);
    17. sb->addWidget(container);
    18. b.show();
    To copy to clipboard, switch view to plain text mode 

  9. The following user says thank you to ChrisW67 for this useful post:

    graciano (10th November 2013)

  10. #7
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Adding QLabel to QMainWindow statusbar

    I see ... didn't get it the first time.
    Thanks

Similar Threads

  1. Replies: 0
    Last Post: 29th July 2013, 10:10
  2. Adding a Layout to QMainWindow
    By Chiggins in forum Qt Programming
    Replies: 2
    Last Post: 7th June 2010, 06:25
  3. Adding control to Statusbar
    By Barry79 in forum Qt Tools
    Replies: 1
    Last Post: 29th April 2009, 10:23
  4. Adding a QSizeGrip to a QMainWindow
    By forrestfsu in forum Qt Programming
    Replies: 6
    Last Post: 9th April 2007, 15:45
  5. Replies: 2
    Last Post: 7th January 2007, 21:07

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.