Regarding the navigation from one window to other
-
Create a new class that inherits QMainWindow.
for example:
@
#include <QMainWindow>class YourWindow : public QMainWindow
{
Q_OBJECT
public:
YourWindow(QWidget *parent = 0);
~YourWindow();
//add other functions you want here
};@If you want the window, "parentless"... you may copy what was done in main.cpp into your MainWindow.cpp:
@YourWindow w;
w.show();@If not:
@YourWindow *w=new YourWindow(this);
w->exec();@Note the difference between show() and exec(). You may read the QWidget documentation about these 2 functions since QMainWindow inherited QWidget.
-
So basically you need to display another window when you click on push button [if I have understood correctly].
Dialog window is best way. You can use QDialog class.@void MainWindow::on_pushButton_clicked()
{
QDialog *dialog = new QDialog();
dialog->setModal(true);
dialog->exec();
}@You can have separate class inherited from QDialog if you wish any design in your dialog window.
-
[quote author="kirangps" date="1352271346"]So basically you need to display another window when you click on push button [if I have understood correctly].
Dialog window is best way. You can use QDialog class.@void MainWindow::on_pushButton_clicked()
{
QDialog *dialog = new QDialog();
dialog->setModal(true);
dialog->exec();
}@You can have separate class inherited from QDialog if you wish any design in your dialog window.[/quote]
Exactly.
But the problem with QDialog was that it blocks all user interaction to your "Main GUI" until it is closed. If you want a "non-blocking" window, use QWidget... but your choice depends on what you need.
-
bq. But the problem with QDialog was that it blocks all user interaction to your “Main GUI” until it is closed. If you want a “non-blocking” window, use QWidget… but your choice depends on what you need.
That's correct, dialog window with above code blocks all user interaction with main window as it is a Modal dialog. You can use Non Modal dialog, like,
@void MainWindow::on_pushButton_clicked()
{
QDialog *dialog = new QDialog();
dialog->setModal(false); //make it true for Modal dialog
dialog->show(); // and use show() instead of exec()
}@ -
sorry for the late reply. I am attaching the code. as the code is having more .cpp and .h files, i am attaching only the page for which the clarification is needed. once again i will tell the aim of the program is listed below:
(1) i want to access the serially transmitted datas from another computer
(2) As soon as the datas are received the same should be displyed in a oscilloscope.Problem to be solved:
(1) I am able to display one window and able to collect the data through serial port. I have placed a push button in that window. wen the push button is clicked i want to generate a new window in which the qwt oscilloscope window has to be displayed.
(2) I will show the line of code which i have written in this program for the sameconnect(ui->openCloseButton, SIGNAL), SLOT));
after the same i have called the osci() function as the one below. void MainWindow::osci() { QMainWindow *osci = new QMainWindow(this); osci->show(); }
Now wen i am clicking a new window is displaying . My question is how to add the components into that new window. or how to include the oscilloscope program of qwt to it .
I was not able to post the entire code here as it is showing exceeding of 6000 characters
I will really gratefull if anybody can give the solution for the one above.
I am conveying my advance thanks to all.expecting a postive reply
-
have you tried reading through the Qwt examples? I relied on their examples when I am developing an application that needs graph.