Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. India
  4. Slot
Forum Update on Monday, May 27th 2025

Slot

Scheduled Pinned Locked Moved India
28 Posts 7 Posters 13.2k Views
  • 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.
  • R Offline
    R Offline
    Revu
    wrote on 22 Feb 2011, 11:04 last edited by
    #14

    @Geroif:I think almost is done.But how to declare the second designer form in the scope of first form in its .cpp file.

    Every fall is to raise higher than Before.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 22 Feb 2011, 11:12 last edited by
      #15

      [quote author="Revu" date="1298372699"]@Geroif:I think almost is done.But how to declare the second designer form in the scope of first form in its .cpp file.[/quote]

      The usual way is to have one cpp class per form file (.ui). To use one of the forms in another cpp file, include the headers as you do for ordinary classes too.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Revu
        wrote on 22 Feb 2011, 11:19 last edited by
        #16

        @Volker:Thanks for that tip.

        Should I have a file(.h) for my second form too?

        Every fall is to raise higher than Before.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on 22 Feb 2011, 11:21 last edited by
          #17

          Yes.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on 22 Feb 2011, 12:06 last edited by
            #18

            Of course!

            Each form should be a class, and a class should have header and cpp (if its not pure inline or template).
            The designer is only some helper tool to not do all the coding for ui representation by hand (what I personally prefer).

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Revu
              wrote on 23 Feb 2011, 05:31 last edited by
              #19

              am not able to get it done...how could I attach my code with the message to get help ?

              Every fall is to raise higher than Before.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Revu
                wrote on 23 Feb 2011, 09:31 last edited by
                #20

                Am getting error after compiling.The code is as follows:
                @#include <QtGui>

                #include "mainwindow.h"
                #include "subWindow.h"

                int main(int argc , char *argv[])
                {
                QApplication app(argc,argv);

                    mainwindow mWindow;
                    mWindow.show();
                    subWindow window;
                    window.show();
                
                    QObject::connect( &mWindow, SIGNAL(Clicked()),
                    &window, SLOT(on_next_clicked()));
                
                    return app.exec();
                

                }
                @

                the error is:

                main.cpp: In function ‘int main(int, char**)’:
                main.cpp:10: error: ‘mainwindow’ was not declared in this scope
                main.cpp:10: error: expected ‘;’ before ‘mWindow’
                main.cpp:11: error: ‘mWindow’ was not declared in this scope
                make: *** [main.o] Error 1

                please help

                Every fall is to raise higher than Before.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on 23 Feb 2011, 10:15 last edited by
                  #21

                  Are you sure this is the whole output? It seems like something is wrong in your mainwindow.h. Please post both the complete compilation output, and the contents of mainwindow.h.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on 23 Feb 2011, 12:08 last edited by
                    #22

                    [quote author="Revu" date="1298453513"]
                    main.cpp: In function ‘int main(int, char**)’:
                    main.cpp:10: error: ‘mainwindow’ was not declared in this scope
                    main.cpp:10: error: expected ‘;’ before ‘mWindow’
                    main.cpp:11: error: ‘mWindow’ was not declared in this scope
                    make: *** [main.o] Error 1

                    please help[/quote]

                    Seems that you should read some C++ tutorial first. This are some basic error messages from the compiler. You must be familiar with header and implementation files before you can use Qt successfully.

                    And as Andre already mentioned, it's hard to analyze the error without the contents of mainwindow.h.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      Revu
                      wrote on 23 Feb 2011, 12:10 last edited by
                      #23

                      the code is as below:
                      @#ifdef MAINWINDOW_H
                      #define MAINWINDOW_H

                      #include<QDialog>
                      #include"subWindow.h"
                      #include "ui_main.h"

                      namespace Ui
                      {
                      class mainwindow;
                      }

                      class mainwindow:public QDialog,public Ui::main
                      {
                      Q_OBJECT

                      public:
                      explicit mainwindow(QWidget *parent=0);
                      ~mainwindow();

                      private slots:
                      void on_next_click();

                      };
                      #endif@

                      Every fall is to raise higher than Before.

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        Revu
                        wrote on 23 Feb 2011, 12:11 last edited by
                        #24

                        @Volker:Thank You for your advice.

                        Can you suggest me few online tutorials to understand the concepts clearly?

                        Every fall is to raise higher than Before.

                        1 Reply Last reply
                        0
                        • R Offline
                          R Offline
                          Revu
                          wrote on 23 Feb 2011, 12:19 last edited by
                          #25

                          Am very new to coding so please me for my mistakes.

                          Every fall is to raise higher than Before.

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            goetz
                            wrote on 23 Feb 2011, 12:37 last edited by
                            #26

                            Change this:

                            @
                            #ifdef MAINWINDOW_H
                            #define MAINWINDOW_H
                            @

                            to this:

                            @
                            #ifndef MAINWINDOW_H
                            #define MAINWINDOW_H
                            @

                            http://www.catb.org/~esr/faqs/smart-questions.html

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              andre
                              wrote on 23 Feb 2011, 12:38 last edited by
                              #27

                              Good catch, Volker!

                              1 Reply Last reply
                              0
                              • R Offline
                                R Offline
                                Revu
                                wrote on 24 Feb 2011, 04:24 last edited by
                                #28

                                @Volker: thank you so much I missed to check that.

                                Every fall is to raise higher than Before.

                                1 Reply Last reply
                                0

                                23/28

                                23 Feb 2011, 12:10

                                • Login

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