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. [SOLVED]Using qmake basics

[SOLVED]Using qmake basics

Scheduled Pinned Locked Moved General and Desktop
13 Posts 4 Posters 6.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.
  • dheerendraD Offline
    dheerendraD Offline
    dheerendra
    Qt Champions 2022
    wrote on last edited by
    #2

    do you have Qt += core gui widgets ?

    Dheerendra
    @Community Service
    Certified Qt Specialist
    http://www.pthinks.com

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #3

      [quote author="Dheerendra" date="1410830730"]do you have Qt += core gui widgets ?[/quote]"core" and "gui" are available by default. You only need to add this line to your .pro file:

      @QT += widgets@

      Charlie_Hdz, since you are using Qt 5.3, have you thought of developing your project inside Qt Creator? It is easier that way, and you don't have to run qmake from the command line.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #4

        Thank you JKSH and that is true as well. Just wanted to recheck and there is not mistake. Also widgets is also added by default if Qt Widgets Project is created.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Charlie_Hdz
          wrote on last edited by
          #5

          Thank you JKSH

          Im following a program that include a few examples of the use of qmake

          Kind Regards,
          Enrique Hernandez
          gearstech.com.mx
          chernandez@gearstech.com.mx

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

            When i just need compile a .cpp file with reference of Qt headers like QTextStream...How can i do it?

            i tried in terminal:

            g++ qtstreamdemo.cpp

            and then:

            qtstreamdemo.cpp:1:23: fatal error: QTextStream: No existe el archivo o el directorio
            #include <QTextStream>
            ^
            compilation terminated.

            Kind Regards,
            Enrique Hernandez
            gearstech.com.mx
            chernandez@gearstech.com.mx

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #7

              You need to provide gcc with the include path to where QTextStream is located. Then you will also have to tell it where the libraries are located as well as link the them.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Charlie_Hdz
                wrote on last edited by
                #8

                Ty SGaist

                Can you help me with a command example?

                Kind Regards,
                Enrique Hernandez
                gearstech.com.mx
                chernandez@gearstech.com.mx

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  That's basic g++

                  @gcc -I/path/to/the/additional/includes -L/path/to/the/additional/libraries -lmylibrary mycppfile.cpp@

                  Anyway, you should rather do something like

                  @
                  mkdir qtstreamdemo
                  cd qtstreamdemo
                  /* write qtstreamdemo.cpp */
                  qmake -project
                  qmake
                  make
                  @

                  If you need additional Qt modules just edit the pro file to add them.

                  Less complicated than writing all what is needed on the command line.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    Charlie_Hdz
                    wrote on last edited by
                    #10

                    [quote author="SGaist" date="1410902182"]That's basic g++

                    @gcc -I/path/to/the/additional/includes -L/path/to/the/additional/libraries -lmylibrary mycppfile.cpp@

                    Anyway, you should rather do something like

                    @
                    mkdir qtstreamdemo
                    cd qtstreamdemo
                    /* write qtstreamdemo.cpp */
                    qmake -project
                    qmake
                    make
                    @

                    If you need additional Qt modules just edit the pro file to add them.

                    Less complicated than writing all what is needed on the command line.
                    [/quote]

                    Thanks a lot,its working, i did something like this:

                    @
                    mkdir qtstreamdemo
                    cd qtstreamdemo
                    //Create the .pro associated with Qt libraries (CONFIG += qt) and //the .cpp
                    qmake -o Makefile qtstreamdemo.pro
                    make
                    ./qtstreamdemo
                    @

                    Kind Regards,
                    Enrique Hernandez
                    gearstech.com.mx
                    chernandez@gearstech.com.mx

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      Charlie_Hdz
                      wrote on last edited by
                      #11

                      Can you help me please?
                      I tried to build this project:

                      @
                      TEMPLATE = app
                      QT += widgets
                      QT += core gui
                      CONFIG += qt
                      SOURCE += qtfirstapp.cpp
                      TARGET = qtfirstapp

                      SOURCES +=
                      qtfirstapp.cpp

                      @

                      and the .cpp
                      @

                      #include <QtGui>

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

                      //Declarations of variables
                      int answer=0;
                      do{
                      //local variables to the loop:
                      int factArg=0;
                      int fact(1);
                      factArg=QInputDialog::getInt(0,"Factorial Calculator","Factorial of: ",1); //Calls a template dialog of int inputs
                      cout<<"User entered: "<<factArg<<endl;
                      int i=2;

                      //Here begins the calculation of Factorial of factArg
                      while (i <= factArg){
                        fact=fact*i;
                        ++i;
                      }
                      
                      QString response=QString("The factorial of %1 is %2. \n%3").arg(factArg).arg(fact)
                       .arg("Compute another factorial?");
                      answer=QMessageBox::question(0,"PlayAgain?",response,QMessageBox::Yes | QMessageBox::No);
                      

                      }while(answer == QMessageBox::Yes);

                      return EXIT_SUCCESS;
                      }

                      @

                      Using Qt Creator works fine, but in the Terminal make these errors:

                      quique@Quique-Lap:~$ cd /home/quique/Escritorio/QtProjects/QtFirstApp
                      quique@Quique-Lap:~/Escritorio/QtProjects/QtFirstApp$ qmake qtfirstapp.pro
                      quique@Quique-Lap:~/Escritorio/QtProjects/QtFirstApp$ make
                      g++ -c -m64 -pipe -O2 -D_REENTRANT -Wall -W -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I. -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I. -o qtfirstapp.o qtfirstapp.cpp
                      qtfirstapp.cpp: In function ‘int main(int, char**)’:
                      qtfirstapp.cpp:6:20: error: variable ‘QApplication app’ has initializer but incomplete type
                      QApplication app(argc,argv);
                      ^
                      qtfirstapp.cpp:15:13: error: ‘QInputDialog’ has not been declared
                      factArg=QInputDialog::getInt(0,"Factorial Calculator","Factorial of: ",1); //Calls a template dialog of int inputs
                      ^
                      qtfirstapp.cpp:27:12: error: ‘QMessageBox’ has not been declared
                      answer=QMessageBox::question(0,"PlayAgain?",response,QMessageBox::Yes | QMessageBox::No);
                      ^
                      qtfirstapp.cpp:27:58: error: ‘QMessageBox’ has not been declared
                      answer=QMessageBox::question(0,"PlayAgain?",response,QMessageBox::Yes | QMessageBox::No);
                      ^
                      qtfirstapp.cpp:27:77: error: ‘QMessageBox’ has not been declared
                      answer=QMessageBox::question(0,"PlayAgain?",response,QMessageBox::Yes | QMessageBox::No);
                      ^
                      qtfirstapp.cpp:28:20: error: ‘QMessageBox’ has not been declared
                      }while(answer == QMessageBox::Yes);
                      ^
                      make: *** [qtfirstapp.o] Error 1

                      I guess is some command in the .pro but i dont know which is...
                      Thank You

                      Kind Regards,
                      Enrique Hernandez
                      gearstech.com.mx
                      chernandez@gearstech.com.mx

                      1 Reply Last reply
                      0
                      • JKSHJ Offline
                        JKSHJ Offline
                        JKSH
                        Moderators
                        wrote on last edited by
                        #12

                        Hi,

                        Error messages contain useful clues, so I recommend that you read them and try to remember what they mean. Most of your errors say '<Class>' has not been declared. That means you haven't #included their headers.

                        You need to #include the header of each class that you use:
                        @
                        #include <QApplication>
                        #include <QInputDialog>
                        #include <QMessageBox>
                        // etc.
                        @

                        I notice that you used #include <QtGui>. This worked in Qt 4, but it doesn't work in Qt 5.

                        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          Charlie_Hdz
                          wrote on last edited by
                          #13

                          Running...

                          #include <QApplication>
                          #include <QInputDialog>
                          #include <QMessageBox>
                          #include <iostream>
                          #include <QTextStream>

                          Thank you all

                          Kind Regards,
                          Enrique Hernandez
                          gearstech.com.mx
                          chernandez@gearstech.com.mx

                          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