Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
Opening dynamically created buttons
I tried to make some dynamically created buttons but the appllication closed when I try to do it or make every buttons in one position in a frame (when a I do it in new window it works but I need in a special created frame several buttons)
//this line makes a problem
// QVBoxLayout *layout=new QVBoxLayout(); //this works
QPushButton *przyc =new QPushButton(buttontext, ui->frame);
QPushButton *przyc2 =new QPushButton(buttontext, ui->frame);
My QT creator 2.7.2 on base qt 5.1.0 version under linux mint
Hi and welcome to devnet,
You do not check whether the value is null.
I guess that you did not apply a layout on your frame in designer.
You right the pointer is null however I applied in Qt creator layout and frame . How to do it correctly?
Go to Designer and look what the Layout really is named.
Then it's available as
and see if that works;
Also you can avoud casting as its of correct layout type already.
now it works how I supposed. I think its difficult to achieve it, without your support I would have spent many hours until find it correctly
Well, Its unclear why layout() didn't work.
It does return the layout for me in a small example.
So I think maybe you changed the type of the layout
and hence when you cast it becomes zero as it was not the right type.
Or something like that.
@mrjj I think I do it how in example but the philosophy of qt frames and layouts I should to learn more.
Thanks for quick answers :)