Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. How to run a C++ code in Qt?

How to run a C++ code in Qt?

Scheduled Pinned Locked Moved Installation and Deployment
123 Posts 5 Posters 108.5k 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.
  • J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 25 Jan 2016, 09:40 last edited by
    #79

    QtCreator should be in C:\Qt\5.6.0\Tools
    You can create a Kit with the right compiler and Qt version in QtCreator under Tools/Options/Build & Run

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    R 1 Reply Last reply 25 Jan 2016, 09:52
    0
    • J jsulm
      25 Jan 2016, 09:40

      QtCreator should be in C:\Qt\5.6.0\Tools
      You can create a Kit with the right compiler and Qt version in QtCreator under Tools/Options/Build & Run

      R Offline
      R Offline
      Rela
      wrote on 25 Jan 2016, 09:52 last edited by
      #80

      @jsulm
      Thanks, could you tell me the exact path of 5.6 beta creator in tools here?

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 25 Jan 2016, 09:57 last edited by
        #81

        If it is there you should find it.
        But here is the path: C:\Qt\5.6.0\Tools\QtCreator\bin\qtcreator.exe

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        R 1 Reply Last reply 25 Jan 2016, 10:14
        0
        • J jsulm
          25 Jan 2016, 09:57

          If it is there you should find it.
          But here is the path: C:\Qt\5.6.0\Tools\QtCreator\bin\qtcreator.exe

          R Offline
          R Offline
          Rela
          wrote on 25 Jan 2016, 10:14 last edited by Rela
          #82

          @jsulm

          Thanks, It works now, but how can I replace it on desktop with previous Qt5.5 creator?

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 25 Jan 2016, 10:32 last edited by
            #83

            You mean you want to have a short-cut on the desktop? Drag and drop qtcreator.exe to the desktop using right mouse button and then select "Create shortcuts here"

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            R 1 Reply Last reply 26 Jan 2016, 11:18
            0
            • J jsulm
              25 Jan 2016, 10:32

              You mean you want to have a short-cut on the desktop? Drag and drop qtcreator.exe to the desktop using right mouse button and then select "Create shortcuts here"

              R Offline
              R Offline
              Rela
              wrote on 26 Jan 2016, 11:18 last edited by
              #84

              @jsulm
              Thanks, I thought I first need to uninstall the previous version.

              1 Reply Last reply
              0
              • S SGaist
                4 Dec 2015, 21:47

                First thing: don't use cout since it will send the text to the console.

                You can simply put a QLabel with hello world as text as central widget of your MainWindow class.

                R Offline
                R Offline
                Rela
                wrote on 26 Jan 2016, 13:51 last edited by
                #85
                This post is deleted!
                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Rela
                  wrote on 26 Jan 2016, 13:55 last edited by
                  #86

                  Previously I tried a simple project to print out "Hello world" in one of my previous posts. The C++ code was written in MSVC 2013 gives output. Here is one of my previous posts related to getting output of C++ code written in MCVS 2013 in Qt5.5.
                  Here is my previous post:
                  "The above output was the debug using "Desktop Qt 5.5.1 MSVC2013 64 bit". I didnt debug with MinGW. The problem is the way I use to get the results in UI.
                  I tried a simple project to print out "Hello world", the C++ code written in MSVC gives output. Could you please take a look at my files:
                  Here are the content of C++ all files.
                  main.cpp
                  Bucky9.cpp
                  stdafx.cpp
                  targetver.h
                  stdafx.h
                  Now I created a Qt widget project, and I added the C++ code stdafx.h, targetver.h, and stdfx.cpp files using "Add existing Files" to the header and source. I didnt add Bucky9.cpp and main.cpp. Instead, I coppied the main.cpp C++ codes in the Qt main.cpp file with a little changes of all files.
                  (Changes: 1- Bucky9 is not included in Qt.
                  2- In stdafx.h #include <char.h> instead of <tchar.h>
                  3- Including #include "stdafx.h" in mainwindow.cpp.

                  Here are the content of all files in Qt project:
                  main.cpp
                  mainwindow.cpp
                  stdafx.cpp
                  stdafx.h
                  targetver.h
                  mainwindow.h"

                  I could get "Hello worlds" with QLabel using Qt5.5 and MCVS 2013. The only difference is that I didnt change <tchar.h> in stdafx.h. Now, when I run it, it builds it, but the run button is not active. Here is the code: Qt code
                  Is there any change when I am working with MCVS 2015 and Qt 5.6 beta? Some of my Qt 5.5. works, but some of them dont work.

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 27 Jan 2016, 06:28 last edited by
                    #87

                    What is the content of your *.pro file?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      Rela
                      wrote on 27 Jan 2016, 10:17 last edited by
                      #88

                      Thanks it worked today, the run button was active and gave "Hello world" in widget.
                      Just I am doing the same with another longer C++ code. I copied all .h and .cpp files to the created Qt project folder and added using
                      "Add existing file" to Qt .h and .cpp files. But instead of main.cpp in Qt, I copied the .cpp code in my PS C++ project. When I run it it gives more than 10 errors like

                      
                      "\\home.org.a\ab\data\Documents\Qt projects\PS7\main.cpp:1060: error: C2664: 'void PSError(char *)': cannot convert argument 1 from 'const char [37]' to 'char *'' in main.cpp file.
                      
                      

                      I changed the the #include <tchar.h> to #include <char.h> in "stdafx.h" file, but the error decreased to two including ```

                      "\\home.org.a\ab\data\Documents\Qt projects\PS7\stdafx.h:11: error: C1083: Cannot open include file: 'char.h': No such file or directory"
                      
                      
                      PS. May I ask why I cannot see my previous posts in this page? I need sometimes to look at them, how can I do that?
                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 27 Jan 2016, 12:19 last edited by
                        #89

                        Just to be clear, are you trying to build MSVC generate code with a MinGW build of Qt ?
                        If so why not just import the code you wrote in your VS project in your Qt project and dump the VS specific files that you anyway will not use in your Qt project ?

                        If you have the infinite scroll activated, just scroll up otherwise you have a at the bottom a page selector.

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

                        R 1 Reply Last reply 27 Jan 2016, 12:39
                        1
                        • S SGaist
                          27 Jan 2016, 12:19

                          Just to be clear, are you trying to build MSVC generate code with a MinGW build of Qt ?
                          If so why not just import the code you wrote in your VS project in your Qt project and dump the VS specific files that you anyway will not use in your Qt project ?

                          If you have the infinite scroll activated, just scroll up otherwise you have a at the bottom a page selector.

                          R Offline
                          R Offline
                          Rela
                          wrote on 27 Jan 2016, 12:39 last edited by Rela
                          #90

                          @SGaist
                          I think I wrote by mistake. I am trying to run my C++ project using Qt Widget project.
                          I have these files VS I copied them in my Qt project folder, and added stdafx.cpp, stdafx.h, targetver.h and O_PS .H to the Qt. Instead of adding "O_PS .cpp" I copied its content to the "main.cpp" in Qt. For "po .cpp" also I just added
                          #include "stdafx.h" to the "mainwindow.cpp". Now I have these files in Qt: Qt

                          The errors were explained in the previous post.

                          1 Reply Last reply
                          0
                          • J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 27 Jan 2016, 12:55 last edited by
                            #91

                            See here: http://stackoverflow.com/questions/4726155/whats-the-use-for-stdafx-h-in-visual-studio
                            stdafx.h seems to be generated by VS, so you should not use it with MinGW

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            R 1 Reply Last reply 27 Jan 2016, 13:15
                            0
                            • J jsulm
                              27 Jan 2016, 12:55

                              See here: http://stackoverflow.com/questions/4726155/whats-the-use-for-stdafx-h-in-visual-studio
                              stdafx.h seems to be generated by VS, so you should not use it with MinGW

                              R Offline
                              R Offline
                              Rela
                              wrote on 27 Jan 2016, 13:15 last edited by
                              #92

                              @jsulm
                              If I understood your post, I dont run the Qt with MinGW, here I run it using Desktop MCVS 2015 compiler, after adding the path of the input data file to the Run of the MCVS 2015 in the project.

                              1 Reply Last reply
                              0
                              • R Offline
                                R Offline
                                Rela
                                wrote on 2 Feb 2016, 13:24 last edited by
                                #93

                                Could you please tell your ideas about my previous question posted 6 days ago?

                                1 Reply Last reply
                                0
                                • J Offline
                                  J Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on 3 Feb 2016, 06:31 last edited by
                                  #94

                                  Please take a look at error messages you get:

                                  "\\home.org.a\ab\data\Documents\Qt projects\PS7\main.cpp:1060: error: C2664: 'void PSError(char *)': cannot convert argument 1 from 'const char [37]' to 'char *'' in main.cpp file.
                                  

                                  Now check the code lines mentioned in these error messages. Error message you posted tells you that you are passing a const char array to a function that takes a non-const char*. This is not allowed.

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0
                                  • R Offline
                                    R Offline
                                    Rela
                                    wrote on 3 Feb 2016, 10:29 last edited by Rela 2 Mar 2016, 10:30
                                    #95

                                    But previously it did not give that error, when I did the same with different versions of Qt5.5 and MCVS 2013. The number of errors

                                     cannot convert argument 1 from 'const char [37]' to 'char *''
                                    

                                    is about 12-13.
                                    However, when I change the

                                    #include <tchar.h>
                                    

                                    to

                                    #inclu```de <char.h>
                                    

                                    in "stdafx.h" file, the error decreased to two including

                                    \\home.org.a\ab\data\Documents\Qt projects\PS7\stdafx.h:11: error: C1083: Cannot open include file: 'char.h': No such file or directory
                                    

                                    errors.

                                    T 1 Reply Last reply 9 Feb 2016, 10:24
                                    0
                                    • R Offline
                                      R Offline
                                      Rela
                                      wrote on 9 Feb 2016, 09:46 last edited by
                                      #96

                                      Could you please reply me?

                                      1 Reply Last reply
                                      0
                                      • R Rela
                                        3 Feb 2016, 10:29

                                        But previously it did not give that error, when I did the same with different versions of Qt5.5 and MCVS 2013. The number of errors

                                         cannot convert argument 1 from 'const char [37]' to 'char *''
                                        

                                        is about 12-13.
                                        However, when I change the

                                        #include <tchar.h>
                                        

                                        to

                                        #inclu```de <char.h>
                                        

                                        in "stdafx.h" file, the error decreased to two including

                                        \\home.org.a\ab\data\Documents\Qt projects\PS7\stdafx.h:11: error: C1083: Cannot open include file: 'char.h': No such file or directory
                                        

                                        errors.

                                        T Offline
                                        T Offline
                                        the_
                                        wrote on 9 Feb 2016, 10:24 last edited by
                                        #97

                                        @Rela

                                        I don't remember that there is any char.h file.

                                        -- No support in PM --

                                        R 1 Reply Last reply 9 Feb 2016, 13:07
                                        0
                                        • T the_
                                          9 Feb 2016, 10:24

                                          @Rela

                                          I don't remember that there is any char.h file.

                                          R Offline
                                          R Offline
                                          Rela
                                          wrote on 9 Feb 2016, 13:07 last edited by
                                          #98

                                          @the_
                                          Thanks, could you please read my last 6 previous posts?

                                          1 Reply Last reply
                                          0

                                          88/123

                                          27 Jan 2016, 10:17

                                          • Login

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