Amir Khojaste
Amir Khojaste

Reputation: 26

How can I have access to values of my Mainwindow in another window? (Qt 5.0.2)

My question might seem simple for you but I'm stuck in it. I've searched around but since I'm new to Qt and OOP I'm a bit confused and can't quiet understand whats going on!

Well, I have written a program in Qt Creator that has two windows. In one window the user enters some numbers in a QTablewidget (lets say some Xs and Ys) and when the user pushes the button "depict graph", I want to open a new window and depict the graph of Xs and Ys in the second window. I have managed to open the second window in Qt and also to depict a random plot in that window. However, I want to get the values of what user entered in my Mainwindow and depict them in the second window. I know it has to do someting with Signals and SLots but I don't know how!

Any help is much appreciated!

Upvotes: 0

Views: 352

Answers (1)

Lahiru Chandima
Lahiru Chandima

Reputation: 24068

If your second window does not need to update when something in first window is changed, you can pass all arguments necessary for second window to its constructor.

If second window needs to update on some event in first window, you can add a method such as update() to the second window and call it with new data whenever such event occurs.

Upvotes: 1

Related Questions