0
votes

I'm trying to implement something like questionnaire. So I have some textedit widgets and some radio buttons(yes/no). I have all of them added into QVBoxLayout. This layout is added into QScrollArea and QScrollArea is added into QTabWidget. I use Qt 4.8.1 and Qt Designer for that.

The problem is that several questions longer than others (for example they take 2 strings instead of one). When i start my app layout makes all textedits to have the same height. So long textedits show only part of textedit widget.

I've tried to use minimumSize property on neccessary questions.It helped a bit. So the height became well but there are some issues with layout. The widgets which I set minimumSize for became overlap other widgets.

Could you please help me with my issue or provide some resources that may help? I'm a very beginner in Qt and that's my first question there. And please note I am not able to upload snapshots because I don't have enough reputation...

3

3 Answers

2
votes

One possible alternative to your implementation of a questionnaire that could help you would be to use a QFormLayout as it is quite designed to do what you're trying to implement.

It provides many features that could help you design your Widget more easily than doing by hand the customization of every TextEdit and Labels.

I think notably about setRowWrapPolicy which you could use to define how your labels are positionned related to their textedits.

Just create a QFormLayout, create the TextEdits and the radio buttons you want to put in, add them to the layout, and set the wrap policy you want (and/or play with the other feature to get things how you want).

0
votes

Try to set scroll->setWidgetResizable(true) on the scroll area.

0
votes

Thanks! But strange thing that setting setWidgetResizable(false) helped me)). But I had to manually set the scroll area height.