Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Regarding the navigation from one window to other
Forum Updated to NodeBB v4.3 + New Features

Regarding the navigation from one window to other

Scheduled Pinned Locked Moved General and Desktop
13 Posts 5 Posters 6.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Code_ReaQtor
    wrote on last edited by
    #4

    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.

    Please visit my open-source projects at https://github.com/Code-ReaQtor.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kirangps
      wrote on last edited by
      #5

      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.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Code_ReaQtor
        wrote on last edited by
        #6

        [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.

        Please visit my open-source projects at https://github.com/Code-ReaQtor.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kirangps
          wrote on last edited by
          #7

          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()
          }@

          1 Reply Last reply
          0
          • I Offline
            I Offline
            issam
            wrote on last edited by
            #8

            Hi, I had the some problem last year in a small project, an application that implement the AHP process.
            So I used the QWizard class.

            So, If QWizard fits your application use it, it is simple !

            http://www.iissam.com/

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sanoop
              wrote on last edited by
              #9

              Thanks alot. i will try the same

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sanoop
                wrote on last edited by
                #10

                hai everybody , thanks for your help. Now i am able to navigate from one window to other.
                I need to add some widgets in the navigated window. But when i am adding it is not seen in the new window. Can anybody help in this. Advance thanks to all

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  sanoop
                  wrote on last edited by
                  #11

                  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 same

                  connect(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

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    Code_ReaQtor
                    wrote on last edited by
                    #12

                    have you tried reading through the Qwt examples? I relied on their examples when I am developing an application that needs graph.

                    Please visit my open-source projects at https://github.com/Code-ReaQtor.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      sanoop
                      wrote on last edited by
                      #13

                      i have read the Qwt examples . but there is no proper guidance

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved