How can I have access to values of my Mainwindow in another window?

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!

There are several ways you can use to do it. Since you are plotting data from a table you should consider passing the model from your QTableWidget to your second window using e.g. a setter so that you'll read the data directly from it to populate your graph. Another option will be to extract the data from your table to e.g. a QVector<QVector> and pass that to your new window.

I figured it out how to do it. I have created two functions in my second window class (plotDialog.cpp) named "setmydataset" and "plotgraph". I also considered two private variables in my second window class for xdata and ydata. In my Mainwindow I create an object of plotDialog type and set the variables xdata and ydata and then plot the graph based on them. The code is as follow:

Above line mostly likely will result in a big baraboom when dialog is going out of scope.
It will result in deleting dialog twice. If it works I guess there is something wrong with platform or compiler.
You either do not provide parent or use operator new when creating QObject subclasses.
Counting that exec was called modal behavior is desired, so