Results 1 to 3 of 3

Thread: Scroll Area inside Dock Widget

  1. #1

    Default Scroll Area inside Dock Widget

    Hi,

    I've used the following code snippet to add scroll area inside dock widget

    Qt Code:
    1. QDockWidget *m_pMapInfoWidget = new QDockWidget(this);
    2. m_pMapInfoWidget->setObjectName(QStringLiteral("Map Info Widget"));
    3.  
    4. m_pMapInfoWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
    5. m_pMapInfoWidget->setAllowedAreas(Qt::RightDockWidgetArea);
    6. m_pMapInfoWidget->setMinimumSize(285, 500);
    7.  
    8. addDockWidget(Qt::RightDockWidgetArea, m_pMapInfoWidget);
    9.  
    10. // Create scroll area for the widget
    11. QScrollArea *m_pMapInfoScrollArea = new QScrollArea();
    12. m_pMapInfoScrollArea->setObjectName(QStringLiteral("MapInfoScrollArea"));
    13. m_pMapInfoScrollArea->setWidgetResizable(true);
    14. m_pMapInfoScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    15. m_pMapInfoScrollArea->setFrameStyle(QFrame::NoFrame);
    16. m_pMapInfoScrollArea->show();
    17.  
    18. // Scroll area content
    19. QWidget *m_pInfoContent = new QWidget();
    20. m_pInfoContent->setObjectName(QStringLiteral("InfoContent"));
    21.  
    22. QGroupBox *m_pGPSGroupBox = new QGroupBox(m_pInfoContent);
    23. m_pGPSGroupBox->setObjectName(QStringLiteral("GPSGroupBox"));
    24. m_pGPSGroupBox->setFont(infoFont);
    25.  
    26. m_pGPSGroupBox->setTitle("Heading");
    27. m_pGPSGroupBox->setGeometry(QRect(3, 20, 270, 170));
    28.  
    29.  
    30. QLabel *m_pLatLabel = new QLabel(m_pGPSGroupBox);
    31. m_pLatLabel->setObjectName(QStringLiteral("LatLabel"));
    32. m_pLatLabel->setGeometry(QRect(20, 30, 51, 16));
    33. m_pLatLabel->setFont(infoFont);
    34. m_pLatLabel->setText("Latitude");
    35.  
    36. m_pMapInfoScrollArea->setWidget(m_pInfoContent);
    37. m_pMapInfoWidget->setWidget(m_pMapInfoScrollArea);
    To copy to clipboard, switch view to plain text mode 

    When executing the above code we are getting a scroll area, but there is no scroll bar in it.
    When i resize the window, we are not getting the scroll bar.
    Kindly help us to resolve this.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Scroll Area inside Dock Widget

    Show after setting the widget, like this...
    Qt Code:
    1. //m_pMapInfoScrollArea->show(); //<<<<<<<<<<<<<<<<<<<<<<<<
    2. ...
    3. m_pMapInfoScrollArea->setWidget(m_pInfoContent);
    4. m_pMapInfoWidget->setWidget(m_pMapInfoScrollArea);
    5. m_pMapInfoWidget->show()
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3

    Default Re: Scroll Area inside Dock Widget

    Hi,

    Thanks for the reply. After adding

    Qt Code:
    1. m_pMapInfoWidget->show();
    To copy to clipboard, switch view to plain text mode 

    We are not able to get the scroll bar. After searching we found that a minimum size must be specified for the Content widget (holding the info)
    to get the scroll bar. That is

    Qt Code:
    1. m_pInfoContent->setMinimumSize(280, 1200);
    To copy to clipboard, switch view to plain text mode 

    Thanks

Similar Threads

  1. Add widget to Scroll area widget contents
    By mythili in forum Qt Programming
    Replies: 4
    Last Post: 16th February 2014, 19:57
  2. Replies: 8
    Last Post: 2nd February 2012, 19:52
  3. Scroll bars in scroll area not comming in scroll area
    By aurora in forum Qt Programming
    Replies: 3
    Last Post: 4th January 2012, 06:50
  4. Replies: 3
    Last Post: 8th December 2010, 05:42
  5. QRubberBand painting in the scroll area widget
    By SkripT in forum Qt Programming
    Replies: 7
    Last Post: 17th January 2006, 16:48

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.