How to use the contents of an object from MainWindow to another window?
**I have a MainWindow with a LineEdit and have another window with a Label. I want to use the contents of LineEdit of MainWindow in Label of the another window.
In short, I would like to know how to use the content of an object from a window in another object of another window.
PS: I am a beginner in QT, please explain in detail step by step how I include this object.
@Ni.Sumi I read the two links, but did not quite understand.
Could you give an example, step by step, using a LineEdit and a Label in different windows?
@rafael01justino You should really learn signals/slots concept, else you will not be able to do much with Qt as it is one of the core concepts.
In this case you probably do not have to use signals/slots. If your main windows creates that another windows then it can set its label. But if you want to change that label when the line edit is changed then you should use signals slots.
QLineEdit has some signals, you can use http://doc.qt.io/qt-5/qlineedit.html#textChanged . Connect it to setText(QString) slot of your QLabel: http://doc.qt.io/qt-5/qlabel.html#text-prop
Here, I made a sample. Please download it here this and try to implement this to your case. This is just rough way to do, I have made two mainwindows. MWindow1 has label, line edit and oush button. click on the pushButton , it opens the second window and write some text in the lineEdit. I made two connect()'s , one is to connect to the label and lineEdit in the same class and other is to connect in other class.
I request you also, to read completely the signal and slot mechanism, as @jsulm mentioned.
Remember, I made it roughly, you should implement the same according to your project/code.
Note: I have used connect in 4.8 and 5.5 way, you can also check the latest signal and slot mechanism in Qt5.7.