Answer the question
In order to leave comments, you need to log in
Qt. How to create with initialization a class object with member-objects on the stack?
This is how I create member objects in the class:
This is how in the constructor:
But how to allocate memory on the stack, and not on the heap?
This is not possible:
QLabel Title;
QLineEdit Input;
QLineEdit Output;
QComboBox UnitWI;
QComboBox UnitWO;
QPushButton Button;
QLabel Title(this);
QLabel Widget::Title(this);
Answer the question
In order to leave comments, you need to log in
I decided. We create objects:
QLabel Title;
QLineEdit Input;
QLineEdit Output;
QComboBox UnitWI;
QComboBox UnitWO;
QPushButton Button;
They then free themselves there (for this you tie them to their parents). Therefore, if you bind to something an element for which no dynamic memory was allocated, then this freer will still release it, which will cause the program to crash. So do as everyone else does - allocate memory and bind.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question