PDA

View Full Version : Populate form after child window open



Bruschetta
27th September 2016, 12:57
Hello everyone,
i'm trying to populate a secondary window lineEdit fields from DB after onclick event in the mainWindow.
Is there any tutorial/guide that i can follow to understand how to achieve my goal?

Thank you for your time and , i hope, answers.

d_stranz
27th September 2016, 18:41
The "Qt way" of communicating information between different parts of a GUI is to use signals and slots. In your case, your main window should probably implement a signal that is emitted in the onclick() method. As arguments to the signal, you can send the information you wish to appear on your secondary window. You will implement a slot in your secondary window that has the same arguments. In this slot, you fill your line edits with the arguments you have been passed.

In the code that constructs the secondary window, connect the main window's signal to the secondary window's slot.

See the Qt signals and slots tutorial (http://doc.qt.io/qt-5/signalsandslots.html).

Bruschetta
30th September 2016, 08:38
Hello Stranz, thank you for the answer.
Signal and Solts seems to be the best solution for my problems,anyway i menaged it to work using QTimer::singleShot(0, &obj, SLOT(function())).
It was easier but i think not the cleansest way...