PDA

View Full Version : qt exandable widgets



eleanor
21st April 2009, 07:28
Hello, I defined an new class (that adds a new line) that consists of:


class attachLine : public QWidget {
public:
attachLine(QWidget *parent=0);

QLabel *location_label;
QLineEdit *location_edit;
QHBoxLayout *location_layout;
QPushButton *open_button;
QLabel *validate_icon;
};

in my main application I need a functionality that a new line will show in one of the QHBoxLayouts when a certain button is pressed.

What I did is:
- I defined a new widget QWidget
- I added lines_layout with addLayout to the main_layout
- set main_layout as layout of QWidget

and when a QPushButton is pressed, I do this:
- I only add the the lines_layout the upper class (attachLine->location_layout) with addLayout

The problem is that this isn't working. Nothing happens when I press the button.
Does anybody have any idea what am I doing wrong. Maybe there's even a class more appropriate to use for this functionality.

Thanks

mcosta
21st April 2009, 08:38
In general, if you use layouts you can hide widgets and layout auto-resizes himself. Remember to use QLayout::setSizeConstraint (QLayout::SetMinAndMaxSize) to the widget's main layout to resize it automatically