Qt: "Expanding" doesn't work inside a layout -
my purpose create scrollable control qvboxlayout inside of has various controls (say buttons) on it. control put on *.ui form. in constructor control write following code:
myscrollarea::myscrollarea(qwidget *parent) : qscrollarea(parent) { // create scrollable container this->container = new qwidget(); // container widget member this->container->setsizepolicy(qsizepolicy::expanding, qsizepolicy::expanding); this->container->setcontentsmargins(qmargins(0,0,0,0)); this->content = new qvboxlayout(); // layout member this->content->setmargin(0); this->content->setspacing(0); (int i=0; i<100; i++) { qpushbutton * widget = new qpushbutton(); widget->settext("button"); widget->setsizepolicy(qsizepolicy::expanding, qsizepolicy::fixed); this->content->addwidget(widget); } this->container->setlayout(this->content); this->content->layout(); this->setwidget(this->container); } my problem: buttons have fixed size , do not expand horizontally. have fixed size. i'd them expand horizontally fill row they're in. how can them expanding horizontally across parent container?
try calling this->setwidgetresizable(true);
Comments
Post a Comment