Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6074199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:21:19+00:00 2026-05-23T10:21:19+00:00

I use an extended QGroupBox as the widget for QDockWidget in my QMainWindow. Here

  • 0

I use an extended QGroupBox as the widget for QDockWidget in my QMainWindow.
Here is the code snippet:

RzPlaneViewerControlPanelWidget::RzPlaneViewerControlPanelWidget(QWidget *parent) : QGroupBox(parent) {
        // TODO Auto-generated constructor stub
        init();

    }

void RzPlaneViewerControlPanelWidget::init()
    {

            QHBoxLayout *hbox=new QHBoxLayout;
            hbox->setSizeConstraint(hbox->SetMinimumSize);
            hbox->setSpacing(0);
            hbox->setStretch(1,0);

            setMaximumHeight(50);

            QScrollBar *scrollbar=new QScrollBar;
            scrollbar->setOrientation(Qt::Horizontal);
            scrollbar->setMouseTracking(true);
            scrollbar->setFocusPolicy(Qt::StrongFocus);
            scrollbar->setMinimum(0);
            scrollbar->setSingleStep(1);



            QLineEdit *qlineedit = new QLineEdit;
            qlineedit->setMaximumWidth(60);
            qlineedit->setReadOnly(true);

            hbox->addWidget(scrollbar);
            hbox->addWidget(qlineedit);

            //hbox->addWidget(new )
            setLayout(hbox);

}

Here is how I add this widget to QDockWidget :

RzPlaneViewerControlPanelWidget *controlPanel=new RzPlaneViewerControlPanelWidget ;
controlPanel->init();

QDockWidget controlPanelDockWidet=new QDockWidget;
controlPanelDockWidet->setAllowedAreas(Qt::BottomDockWidgetArea);
controlPanelDockWidet->setFeatures(QDockWidget::DockWidgetVerticalTitleBar);
controlPanelDockWidet->setWidget(controlPanel);

But the ScrollBar is not stretched as I expected –
Here’s how it looks like –

http://oi56.tinypic.com/5mzf5y.jpg

This is what I want –

http://oi55.tinypic.com/23wv3tf.jpg

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:21:20+00:00Added an answer on May 23, 2026 at 10:21 am

    From a quick read, I’d try doing:

    hbox->addWidget(scrollbar, 1);
    

    The second (optional) argument to addWidget is the stretch factor. From the Qt docs:

    If the stretch factor is 0 and nothing else in the QBoxLayout has a stretch factor greater than zero, the space is distributed according to the QWidget:sizePolicy() of each widget that’s involved.

    Also, note that your:

    hbox->setStretch(1,0);
    

    call does not have any effect, as it is setting the qlineedit‘s stretch factor to 0, but that’s already the default.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am all very new to this and am trying to use extended hex
I am trying to use a variable to get a function in a extended
Here is a related manager I wrote: class PortfolioItemManager(models.Manager): use_for_related_fields = True def extended(self):
I have two ListBoxes, both use Extended SelectionMode. The ItemsSource of the first is
Do you know some real examples of implementation and real use of extended XLink
I use SimpleCursorAdapter and GridActivity (extended Activity written by me based on ListActivity) to
Is there a way to use my own Dialog-extended class with an AlertBuilder style?
I use Extended WPF Toolkit BusyIndicator My Xaml <extToolkit:BusyIndicator Name=wait IsBusy=False Cursor=Wait Grid.ColumnSpan=3 Margin=10,10,10,10/>
How to use Extended Audio File Services: ExtAudioFileRead to Performs a synchronous, sequential read
To All, We are wanting to use Extended Properties as part of our database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.