Raz0rEdge
13th November 2012, 15:22
Hello,
I will have a QVBoxLayout that will house a series of labels and custom button widgets.
I'm implementing a custom button widget based on QAbstractButton that takes a QList of QStrings and displays one of them as the default text and then has a downward facing arrow next to the string if list contains other strings. When the user clicks on the button, I want to show a drop-down (but flat) box underneath the button I already have with the other strings from the list.
I'm overriding the sizeHint() to return a fixed size for the button based on the font and overriding paintEvent() to do all the custom drawing. Since sizeHint() is returning the size of the button, in paintEvent() the rect() that I can used to draw is 200x48 which is fine. However, I want to dynamically expand the entire widget vertically to add the necessary number of additional button choices underneath.
I've looked at using rect().adjust/adjusted to expand the rect() and qDebug() shows that the rect() has grown as needed, but I also want the layout to expand to handle the newly expanded button widget so that the options are visible. And when a new selection is made or another button is selected, I will shrink the widget back to it's original size and I want the layout to shrink back down.
I know that I can create a QVboxLayout and add a QGroupBox with a bunch of widgets and when I call the show() and hide() functions, the layout expands and shrink as needed.
So my question is, what do I have to trigger/return/emit from my custom widget to allow the layout to expand to show my newly expanded widget?
I've attached a couple of screenshots from our UI design to show that I'm talking about. The image with Bottom/Top shows the buttons on the right in their collapsed form. The image with Pressure shows the button in its expanded form with the Radiation entry being pushed down to accommodate the larger button. Once the user selects one of the options, the button would collapse and the Radiation line would now end up right underneath Pressure just like Bottom/Top..
Regards
I will have a QVBoxLayout that will house a series of labels and custom button widgets.
I'm implementing a custom button widget based on QAbstractButton that takes a QList of QStrings and displays one of them as the default text and then has a downward facing arrow next to the string if list contains other strings. When the user clicks on the button, I want to show a drop-down (but flat) box underneath the button I already have with the other strings from the list.
I'm overriding the sizeHint() to return a fixed size for the button based on the font and overriding paintEvent() to do all the custom drawing. Since sizeHint() is returning the size of the button, in paintEvent() the rect() that I can used to draw is 200x48 which is fine. However, I want to dynamically expand the entire widget vertically to add the necessary number of additional button choices underneath.
I've looked at using rect().adjust/adjusted to expand the rect() and qDebug() shows that the rect() has grown as needed, but I also want the layout to expand to handle the newly expanded button widget so that the options are visible. And when a new selection is made or another button is selected, I will shrink the widget back to it's original size and I want the layout to shrink back down.
I know that I can create a QVboxLayout and add a QGroupBox with a bunch of widgets and when I call the show() and hide() functions, the layout expands and shrink as needed.
So my question is, what do I have to trigger/return/emit from my custom widget to allow the layout to expand to show my newly expanded widget?
I've attached a couple of screenshots from our UI design to show that I'm talking about. The image with Bottom/Top shows the buttons on the right in their collapsed form. The image with Pressure shows the button in its expanded form with the Radiation entry being pushed down to accommodate the larger button. Once the user selects one of the options, the button would collapse and the Radiation line would now end up right underneath Pressure just like Bottom/Top..
Regards