Manually adjust geometry in custom widget
I have a subclassed widget that I paint on. What I want to do is is click on a zoom in button and have the widget expand horizontally. Right now what happens is I click on zoom in and the widget stays the same size. Here is a snippet of what I am currently doing with the resizing.
Code:
{
setGeometry(0,0,base_width,base_height);
}
Chart::set_resize(int w, int h)
{
resize(size);
}
What am I doing wrong?
Any suggestions?
Thank You
Re: Manually adjust geometry in custom widget
Re: Manually adjust geometry in custom widget
Re: Manually adjust geometry in custom widget
Quote:
Originally Posted by
Rooster
it is in a layout
You don't resize widgets by hand when they are in a layout. The layout is responsible for maintaining their geometries. Just read the link I gave, layouts resize widgets according to those rules listed in the documentation.
Re: Manually adjust geometry in custom widget
Ok,
I created a custom layout similar to what is in the link. I placed the widget in the layout and now I want to expand the layout/widget size when I click on a button to zoom in. How do I get the layout to expand when I click this button. Also, once the width get to a certain size, how do I get it to stop expanding and add a scroll bar so I can scroll over.
Re: Manually adjust geometry in custom widget
Quote:
Originally Posted by
Rooster
I placed the widget in the layout and now I want to expand the layout/widget size when I click on a button to zoom in. How do I get the layout to expand when I click this button.
If the widget is in a layout, call QWidget::updateGeometry() to notify the layout system that sizeHint() or sizePolicy() of that widget has changed. If you place it inside a scroll area like adviced below, you may call QWidget::adjustSize().
Quote:
Also, once the width get to a certain size, how do I get it to stop expanding and add a scroll bar so I can scroll over.
Place the widget inside a QScrollArea.
Re: Manually adjust geometry in custom widget
Thank you for the advise everthing works great now.