Results 1 to 5 of 5

Thread: How to do statusbar with separator or with frame.

  1. #1
    Join Date
    May 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to do statusbar with separator or with frame.

    I want to do statusbar with any visual separator such as frame or horizontal line, but I don't know how to do this..
    I try this:
    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addWidget(label1);
    mainLayout->addWidget(label2);
    bar = statusbar()->setLayout(mainLayout);

    but this don't work

  2. #2
    Join Date
    May 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to do statusbar with separator or with frame.

    Style Sheets?

  3. #3
    Join Date
    May 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to do statusbar with separator or with frame.

    ok, now I know how to do this..
    Is there any way to place several QLabel on statusBar()? I have done setLayout() but this don't work

  4. #4
    Join Date
    May 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to do statusbar with separator or with frame.

    now I have one question - why setLayout don't work on qstatusbar?
    I want to use setAligment() with QLabel, but it has no effect..

    lbl->setAligment(Qt::AlignCentre);
    bar->addWidget(lbl);

    but lbl place in the left corner..
    Last edited by Usernаme; 22nd May 2010 at 05:14.

  5. #5
    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: How to do statusbar with separator or with frame.

    QStatusBar already has its own horizontal layout that you can just add widgets to:
    Qt Code:
    1. #include <QtGui>
    2. #include <QDebug>
    3.  
    4.  
    5. int main(int argc, char **argv)
    6. {
    7. QApplication app(argc, argv);
    8.  
    9.  
    10. qDebug() << win.statusBar()->layout();
    11.  
    12. // Global
    13. win.statusBar()->setStyleSheet(
    14. "QStatusBar::item { border: 1px solid red; border-radius: 3px; } "
    15. );
    16.  
    17. // or get more specific
    18. // win.statusBar()->setStyleSheet(
    19. // "QStatusBar::item { border: none; } "
    20. // "QStatusBar QLabel { border: 1px solid blue; border-radius: 3px; }"
    21. // );
    22.  
    23. QLabel *label1 = new QLabel("Text");
    24. label1->setMinimumSize(label1->sizeHint());
    25.  
    26. QLabel *label2 = new QLabel("More text");
    27. label2->setAlignment(Qt::AlignCenter);
    28.  
    29. win.statusBar()->addWidget(label1);
    30. win.statusBar()->addWidget(label2, 1);
    31.  
    32. win.show();
    33. return app.exec();
    34. }
    To copy to clipboard, switch view to plain text mode 

    Your widget is given its minimum size unless you do something like set a stretch factor. Centre alignment means nothing if the box fits its content.
    Last edited by ChrisW67; 22nd May 2010 at 07:29. Reason: Added alignment

Similar Threads

  1. Frame around whole statusbar
    By binaural in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2010, 18:14
  2. Video Parsing - Frame by Frame
    By ctote in forum Qt Programming
    Replies: 3
    Last Post: 15th February 2010, 18:30
  3. Separator in box layout
    By drhex in forum Qt Programming
    Replies: 1
    Last Post: 30th September 2009, 22:36
  4. Previous frame inner to this frame(corrupt stack?)
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 28th May 2007, 01:35
  5. Previous frame inner to this frame(corrupt stack?)
    By coralbird in forum Qt Programming
    Replies: 17
    Last Post: 29th April 2006, 01:42

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.