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. Still working with tutorials...

Still working with tutorials...

Scheduled Pinned Locked Moved General and Desktop
22 Posts 6 Posters 8.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.
  • D Offline
    D Offline
    dangelog
    wrote on last edited by
    #2

    Why don't you just tell creator to open the .pro file of the tutorial?

    Software Engineer
    KDAB (UK) Ltd., a KDAB Group company

    1 Reply Last reply
    0
    • mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by
      #3

      I'm not following...what would that accomplish.

      I don't think I've made my desires clear here...I don't want to just step through some pre-made tutorials. I need to learn the tools as well as the code. In a couple of months, I'm going to be designing a UI for commercial purposes. I need a tool like Qt for this, and my initial inclination is that I'd like to use Qt...if I can get to understanding it.

      But, as I said before, understanding the Qt coding is one thing; understanding how (and when) to use the tools is another.

      If you think going through the pre-fab tutorials will help, great...I'll do it. I just wish there were some tutorials on the Qt environment (if you will) as well as code examples.

      Thanks.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #4

        If you use QtCreator to create a new project, it will create some files for you:

        for an executable:

        • a main.cpp
        • a class.cpp
        • a class.h

        where class represents the main class of your application (could be QMainWindow derived, QDialog derived, QWidget derived). Why should you create a project without knowing, which type of main window you need? And if you really don't know:
        delete the classes after creation.

        The normal way is, create a project and create the source files in the project.

        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
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #5

          You have some choices:

          1. let Qt Creator create a new GUI project for you
          This basically creates a .pro file, a main.cpp and a form.h + form.cpp (and maybe a form.ui if you want). You must know in advance what type your form will be (Widget, Dialog, MainWindow), but you can always change afterwards

          2. let Qt Creator create a new console application for you
          This creates a .pro and main.cpp, but no form files and disables the GUI in the .pro file. You will have to remove the "QT -= gui" from the .pro file if you want to add GUI classes afterwards.

          3. do it yourself
          create the .pro file and main.cpp manually and open the .pro in Qt Creator

          If you are not sure what's the best option for you - just play around. Create new projects from either option and look what's in there. This way you learn much more than from asking "what should I do". It's the same path as with learning how to ride a bicycle: you can read a thousand books on it but you will learn it only by try and error.

          Since you are still in the learning phase of the tools: just go ahead and click on the buttons. If you trash your project, delete it and start over from scratch. No animals will be harmed in this process :-)

          [EDIT formatting, Volker]

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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Smar
            wrote on last edited by
            #6

            I recommend not to use any IDE at the start at all. If you do it by hand, you actually can learn how it works from the low level, get used to commands Qt is using and feel comfortable if you ever need to do something in different environment than the one you are mostly working on.

            For example, type / copy the example file, go to command line, run qmake -project, qmake, make and run the binary.

            Then you could try to understand what those steps actually do... And after it, depending of the type of the project you have, adjust your workflow towards that, and make Qt usable there.

            1 Reply Last reply
            0
            • mzimmersM Offline
              mzimmersM Offline
              mzimmers
              wrote on last edited by
              #7

              [quote author="Gerolf" date="1295248677"]If you use QtCreator to create a new project, it will create some files for you:

              for an executable:

              • a main.cpp
              • a class.cpp
              • a class.h

              where class represents the main class of your application (could be QMainWindow derived, QDialog derived, QWidget derived). Why should you create a project without knowing, which type of main window you need? And if you really don't know:
              delete the classes after creation.

              The normal way is, create a project and create the source files in the project.[/quote]

              OK, here's a very simple example of what I'm talking about. I found this demo somewhere:
              @#include <QApplication>
              #include <QPushButton>

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

               QPushButton hello("Hello world!");
               hello.resize(100, 30);
              
               hello.show();
               return app.exec();
              

              }
              @

              So...assuming I wanted to create a project for this, what would be the recommended method? I don't have a .h file; it's all self contained.

              1 Reply Last reply
              0
              • mzimmersM Offline
                mzimmersM Offline
                mzimmers
                wrote on last edited by
                #8

                Hey, Volker –

                Thanks for the answer. So, if I infer from you correctly, the only essentials are a source file and a project file? Is there some information online specifically about the project file syntax? Perhaps I'll take smar's advice and begin from the command line, though it isn't my first choice.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #9

                  Yepp, that's enough. For your little project consisting of a main.cpp and nothing else, you only need a .pro file. You can create one by calling

                  @
                  qmake -project
                  @

                  in the directory containing the main.cpp.

                  See the "Getting Started Programming with Qt":http://doc.qt.nokia.com/latest/gettingstartedqt.html, it explains how to do this. Translations into various languages are available in the "wiki":http://developer.qt.nokia.com/wiki/Category:Learning::GettingStarted.

                  Once you have a .pro file, just open it in Qt Creator (using the file menu or Ctrl-O/Cmd-O) and you're done. No need to create a new project in this case.

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

                  1 Reply Last reply
                  0
                  • mzimmersM Offline
                    mzimmersM Offline
                    mzimmers
                    wrote on last edited by
                    #10

                    OK...so I created a directory, created a source file and a .pro file. I ran qmake on the .pro file, and now I have this:
                    @
                    -rw-r--r-- 1 mzimmers mzimmers 594 Jan 17 14:15 Info.plist
                    -rw-r--r-- 1 mzimmers mzimmers 542 Jan 17 14:00 hello.cpp
                    -rw-r--r-- 1 mzimmers mzimmers 32 Jan 17 14:15 hello.pro
                    drwxr-xr-x 5 mzimmers mzimmers 170 Jan 17 14:15 hello.xcodeproj
                    @

                    No binary file...so, now I have to run regular make, I guess?

                    [EDIT: markup, Volker]

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on last edited by
                      #11

                      If you want to continue on the command line then this "wiki article":http://developer.qt.nokia.com/wiki/Generate_Makefiles_instead_of_XCode_projects_on_Mac_OS_X will help you.

                      If you want to use Qt Creator, just open the .pro file in Creator, it runs qmake for you.

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

                      1 Reply Last reply
                      0
                      • mzimmersM Offline
                        mzimmersM Offline
                        mzimmers
                        wrote on last edited by
                        #12

                        Really? Just opening the .pro file causes qmake to run?

                        Also, from one of the instructional videos (which might be out of date by now), I got the impression that one needed to run qmake, then run make. True or not?

                        I'm also curious: is it OK to go back and forth between a CLI and Creator for a particular project, or is it better to choose one and stick to it?

                        Thanks.

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

                          [quote author="mzimmers" date="1295304369"]
                          I'm also curious: is it OK to go back and forth between a CLI and Creator for a particular project, or is it better to choose one and stick to it?

                          Thanks.[/quote]

                          It’s best to learn both. You can go around with only one. Your pick, and your timeline and interest what you actually want to accomplish :)

                          1 Reply Last reply
                          0
                          • mzimmersM Offline
                            mzimmersM Offline
                            mzimmers
                            wrote on last edited by
                            #14

                            [quote author="Smar" date="1295304606"]
                            [quote author="mzimmers" date="1295304369"]
                            I'm also curious: is it OK to go back and forth between a CLI and Creator for a particular project, or is it better to choose one and stick to it?

                            Thanks.[/quote]

                            It’s best to learn both. You can go around with only one. Your pick, and your timeline and interest what you actually want to accomplish :)[/quote]

                            What I meant was, for a particular project...is it best to use only one of the two interfaces, or can you flip-flop without repercussions? Put another way...is the CLI compatible with Creator and the other GUI tools?

                            Thanks.

                            1 Reply Last reply
                            0
                            • G Offline
                              G Offline
                              goetz
                              wrote on last edited by
                              #15

                              [quote author="mzimmers" date="1295304369"]Really? Just opening the .pro file causes qmake to run?

                              Also, from one of the instructional videos (which might be out of date by now), I got the impression that one needed to run qmake, then run make. True or not?

                              I'm also curious: is it OK to go back and forth between a CLI and Creator for a particular project, or is it better to choose one and stick to it?

                              Thanks.[/quote]

                              Qt Creator calls qmake and make for you, captures the output and can bring you to the point in the code where the error happened.

                              It is perfectly ok to switch between CLI and Creator. Although you should keep in mind that the shadow builds, that Creator enables by default, reside in another directory. You should know what you're doing, otherwise you can mess up thing.

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

                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                goetz
                                wrote on last edited by
                                #16

                                [quote author="mzimmers" date="1295304889"]
                                What I meant was, for a particular project...is it best to use only one of the two interfaces, or can you flip-flop without repercussions? Put another way...is the CLI compatible with Creator and the other GUI tools?
                                [/quote]

                                Shortly: yes.

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

                                1 Reply Last reply
                                0
                                • mzimmersM Offline
                                  mzimmersM Offline
                                  mzimmers
                                  wrote on last edited by
                                  #17

                                  Shadow builds...that's a term I haven't come across yet. I assume that is for some default target that Creator keeps track of? I've done some tutorials that have resulted in subdirectories like tutorial6 AND tutorial6-build-desktop...is this what you're talking about? Oddly enough, it doesn't happen all the time.

                                  Also, per the Wiki you cited above: I don't seem to have a mkspecs directory anywhere. Was I supposed to create this myself?

                                  Thanks.

                                  1 Reply Last reply
                                  0
                                  • G Offline
                                    G Offline
                                    goetz
                                    wrote on last edited by
                                    #18

                                    A shadow build is a build setup and cycle (creating intermediate and object files as well as the final executable or lib) in an directory outside your source tree.

                                    Regarding the wiki article: You do have the dir somewhere, it's where your Qt libs are installed. The actual directory depends on your installation.

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

                                    1 Reply Last reply
                                    0
                                    • mzimmersM Offline
                                      mzimmersM Offline
                                      mzimmers
                                      wrote on last edited by
                                      #19

                                      [quote author="Volker" date="1295307950"]Regarding the wiki article: You do have the dir somewhere, it's where your Qt libs are installed. The actual directory depends on your installation.
                                      [/quote]

                                      I've done a search on my entire HD for a file/directory with that name...nothing. I wonder if I botched something in the installation?

                                      1 Reply Last reply
                                      0
                                      • G Offline
                                        G Offline
                                        goetz
                                        wrote on last edited by
                                        #20

                                        [quote author="mzimmers" date="1295308733"]
                                        I've done a search on my entire HD for a file/directory with that name...nothing. I wonder if I botched something in the installation?[/quote]

                                        No, it must be on your HD otherwise qmake would not work at all. You can try

                                        @
                                        locate mkspecs
                                        @

                                        in the shell (CLI).

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

                                        1 Reply Last reply
                                        0
                                        • mzimmersM Offline
                                          mzimmersM Offline
                                          mzimmers
                                          wrote on last edited by
                                          #21

                                          Right you were...I forgot that Mac OS X hides a bunch of files from me. I found the directory now.

                                          Now, a really newbie question: when might I want to make XCode projects instead of conventional makefiles?

                                          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