Results 1 to 6 of 6

Thread: Unable to minize space b/n colored QWidget and size adjustment pane of QDockWidget

  1. #1
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Unable to minize space b/n colored QWidget and size adjustment pane of QDockWidget

    I've created 2 QDockWidgets in MainWindow and added QWidget to each. I tried to color each of these widget with some color, but I find some space between size adjustment bar & color. What would be problem with this? Thank you.
    Screenshot.jpg

    Code:

    MainWindow.h
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QtGui/QMainWindow>
    5. #include <QWidget>
    6. #include <QHBoxLayout>
    7. #include <QFrame>
    8. #include <QPushButton>
    9. #include <QTabWidget>
    10. #include <QMenu>
    11. #include <QAction>
    12. #include <QDockWidget>
    13.  
    14. class MainWindow : public QMainWindow
    15. {
    16. Q_OBJECT
    17.  
    18. public:
    19. MainWindow(QWidget *parent = 0);
    20. ~MainWindow();
    21. void baseLayerSettings(void);
    22.  
    23. private:
    24. QFrame *baseLayer;
    25. QWidget *headerWidget, *footerWidget;
    26. QPushButton *tab1_Button1, *tab1_Button2, *tab2_Button1, *tab1_Button3, *startMenu_button;
    27. QMenu *startMenu;
    28. QAction *menuAction;
    29. QDockWidget *headerDock, *centerDock, *footerDock;
    30. QHBoxLayout *footerLayout;
    31. };
    To copy to clipboard, switch view to plain text mode 

    MainWindow.cpp
    Qt Code:
    1. #include "mainwindow.h"
    2.  
    3. MainWindow::MainWindow(QWidget *parent)
    4. : QMainWindow(parent)
    5. {
    6. baseLayerSettings();
    7. setCentralWidget(baseLayer);
    8.  
    9. }
    10.  
    11. MainWindow::~MainWindow()
    12. {
    13.  
    14. }
    15.  
    16. void MainWindow::baseLayerSettings(void)
    17. {
    18. headerDock = new QDockWidget(this);
    19. headerDock->setMinimumHeight(70);
    20. headerDock->setFeatures(QDockWidget::NoDockWidgetFeatures);
    21. baseLayer = new QFrame(this);
    22. baseLayer->setStyleSheet("background-color: rgba(245, 250, 250, 255);");
    23. footerDock = new QDockWidget(this);
    24. footerDock->setMinimumHeight(70);
    25. footerDock->setFeatures(QDockWidget::NoDockWidgetFeatures);
    26.  
    27. this->setCentralWidget(baseLayer);
    28. this->addDockWidget(Qt::TopDockWidgetArea, headerDock);
    29. this->addDockWidget(Qt::BottomDockWidgetArea, footerDock);
    30.  
    31. startMenu = new QMenu;
    32. startMenu->setStyleSheet("QMenu::item {padding: 1px 10px 1px 20px; background-color: rgba(245, 250, 250, 255); height: 35px;};");
    33. startMenu->setStyleSheet("QMenu::item:selected { background-color: rgba(109, 146, 155, 255); }");
    34. startMenu->addAction("Break-Shift");
    35. startMenu->addAction("Logout");
    36. startMenu->addAction("Shutdown");
    37.  
    38. startMenu_button = new QPushButton(tr("Menu"));
    39. startMenu_button->setFixedSize(75, 40);
    40. startMenu_button->setStyleSheet("border-style: outset; border-width: 1px; border-radius: 10px; border-color: blue; font-family: Monaco; font: 16px; color: rgba(4, 98, 148, 255); background-color: rgba(183, 175, 163, 255); min-width: 5em; min-height : 25px;");
    41. startMenu_button->setStyleSheet("QPushButton:pressed { background-color: darkgray; font-family: Monaco; font-style: italic; color: rgba(29, 49, 122, 255)}");
    42. startMenu_button->setMenu(startMenu);
    43.  
    44. headerWidget = new QWidget;
    45. headerWidget->setStyleSheet("background-color: rgba(172, 209, 233, 255);");
    46. headerDock->setWidget(headerWidget);
    47. footerDock->setWidget(startMenu_button);
    48.  
    49. footerWidget = new QWidget;
    50. footerWidget->setStyleSheet("background-color: rgba(232, 208, 169, 255);");
    51. footerDock->setWidget(footerWidget);
    52.  
    53. footerLayout = new QHBoxLayout;
    54. footerWidget->setLayout(footerLayout);
    55. footerLayout->addWidget(startMenu_button, 0, Qt::AlignLeft | Qt::AlignBottom);
    56. startMenu_button->show();
    57.  
    58. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    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: Unable to minize space b/n colored QWidget and size adjustment pane of QDockWidge

    That is the title bar of the dock widget.

    If you want two vertical resizable but otherwise fixed panels at top and bottom then why not use a QSplitter?

  3. #3
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Unable to minize space b/n colored QWidget and size adjustment pane of QDockWidge

    Hi Chris,
    Thanks for your reply. Which widget can I add to splitter instead of QDockWidget ? Does normal QWidget solve my purpose?

  4. #4
    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: Unable to minize space b/n colored QWidget and size adjustment pane of QDockWidge

    Any widget you like. QWidget is a generic empty container that you can use, but presumably you want something in these panels.

  5. #5
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Unable to minize space b/n colored QWidget and size adjustment pane of QDockWidge

    Hi Chris,
    Thanks again. I need some sort of help from you. On a mainwindow, I need 3 sections like header, body, footer. Each section contains some widgets like tabs, pushbuttons, labels, progressbars, etc. These widgets in each section changes according to the menu. Can u help me in choosing corresponding base widgets for each section. Thank you.

  6. #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: Unable to minize space b/n colored QWidget and size adjustment pane of QDockWidge

    For each panel that is not an out-of-the-box widget you create a HeaderWidget/BodyWidget/FooterWidget class derived from QWidget (or whatever). In the constructor you build the UI (sub-widgets and layout) that the widget should contain. That construction code would be the same as whatever you intended to be in the dock widgets.

    In your main window constructor you create an object of each of the three widgets classes, and add them to a QSplitter and add that QSplitter to the main window layout to make your main UI.

    All of that can be done with Designer or by hand coding. There are buckets of hand-coded examples in the documentation.

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

    rawfool (29th November 2011)

Similar Threads

  1. creating a QWidget in the global space
    By wambagilles in forum Qt Programming
    Replies: 4
    Last Post: 8th May 2011, 18:54
  2. Replies: 2
    Last Post: 6th April 2010, 21:42
  3. font size in Application Output Pane
    By piotr.dobrogost in forum Qt Tools
    Replies: 0
    Last Post: 4th August 2009, 20:55
  4. QDockWidget size
    By user in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2009, 20:35
  5. QDockWidget Size
    By kiker99 in forum Qt Programming
    Replies: 9
    Last Post: 31st March 2007, 16:15

Tags for this Thread

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.