Results 1 to 6 of 6

Thread: Why QStatusBar do not at the bottom?

  1. #1
    Join Date
    Sep 2009
    Location
    Nanjing, China
    Posts
    46
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Why QStatusBar do not at the bottom?

    I put a QStatusBar in a QMdiSubWindow. Then I added a QGraphicsView and this QStatusBar into a QVBoxLayout and wanted to get a subwindow just like the QMainWindow. But when I did this, I found that if I resized the subwindow draging mouse the QStatusBar would not at the bottom of QMdiSubWindow.(The red bar is the QStatusBar.) I don't know why. Can anyone help me? Thank you all!

    Last edited by FinderCheng; 28th September 2009 at 15:12.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Why QStatusBar do not at the bottom?

    show us some code, so we don't have to guess...

    from looking at your screenshot:
    check the margins of your layout.

  3. #3
    Join Date
    Sep 2009
    Location
    Nanjing, China
    Posts
    46
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why QStatusBar do not at the bottom?

    Quote Originally Posted by FinderCheng View Post
    I put a QStatusBar in a QMdiSubWindow. Then I added a QGraphicsView and this QStatusBar into a QVBoxLayout and wanted to get a subwindow just like the QMainWindow. But when I did this, I found that if I resized the subwindow draging mouse the QStatusBar would not at the bottom of QMdiSubWindow.(The red bar is the QStatusBar.) I don't know why. Can anyone help me? Thank you all!

    Yeah, here are some related code.

    Qt Code:
    1. // projectwindowpanel.cpp
    2. // code in main panel with a view which extends QGraphcisView and a status bar
    3. // sizeHint() of this view has be overrideed in order to show the full image
    4. view = new ProjectView(project, this);
    5. QSize viewSize = view->sizeHint();
    6. view->setGeometry(0, 0, viewSize.width(), viewSize.width());
    7.  
    8. statusBar = new QStatusBar(this);
    9. statusBar->setGeometry(0, viewSize.height(), viewSize.width(), 15);
    10. statusBar->setStyleSheet(QString("background-color: red"));
    11.  
    12. vbox->setMargin(0);
    13. vbox->setSpacing(0);
    14. vbox->addWidget(view, 0, Qt::AlignHCenter);
    15. vbox->addWidget(statusBar);
    16. setLayout(vbox);
    17.  
    18. // override sizeHint() in projectwindowpanel.cpp
    19. QSize GPF::ProjectWindowPanel::sizeHint() const
    20. {
    21. return QSize(view->sizeHint().width(), view->sizeHint().height() + 15);
    22. }
    23.  
    24. //======================
    25. // projectwindow.cpp
    26. // project window extends QMdiSubWindow with a minimum size
    27. // and set project window panel as its centre widget
    28. setMinimumSize(200, 200);
    29.  
    30. mainPanel = new ProjectWindowPanel(project, this);
    31. setWidget(mainPanel);
    To copy to clipboard, switch view to plain text mode 

    PS: I have removed the sizeHint() in projectwindowpanel.cpp, the problem is still there.
    Last edited by FinderCheng; 29th September 2009 at 02:39.

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Why QStatusBar do not at the bottom?

    calling setGeometry when using QLayout is of no use.

    I'd try:
    * remove the setGeometry() calls
    * remove the sizeHint() implementation
    * remove the setMinimumSize() call - when everything works, try setting the minimum size on the graphicsview

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Why QStatusBar do not at the bottom?

    did you notice QMainWindow::setStatusBar()?

  6. #6
    Join Date
    Sep 2009
    Location
    Nanjing, China
    Posts
    46
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why QStatusBar do not at the bottom?

    Quote Originally Posted by Lykurg View Post
    Yeah, but I put this QStatusBar in a subclass of QMdiSubWindow not QMainWindow.

    By the way, I have set the ProjectView, the main panel which is white, to be fixed size. When I remove this code, it is just fine. But I need it to be fixed. Then I added qDebug in resizeEvent of ProjectWindowPanel and found that the size did not change when I resize the subwindow. I think it is because the main panel of it is fixed size...
    Last edited by FinderCheng; 29th September 2009 at 09:55.

Similar Threads

  1. Subclass QStatusBar
    By 1111 in forum Qt Programming
    Replies: 2
    Last Post: 20th February 2009, 10:14
  2. QTableWidget - scrolling to bottom of the table
    By mkhoang in forum Qt Programming
    Replies: 4
    Last Post: 12th November 2008, 17:21
  3. Replies: 7
    Last Post: 15th November 2007, 17:19
  4. Replies: 1
    Last Post: 11th September 2007, 13:34
  5. Keeping focus at bottom of QListView
    By jakamph in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2006, 14:45

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.