Important: Please read the Qt Code of Conduct -

Qt 5.0.1

  • Hello
    I have some questions to ask as a begginner

    1 / How to create own class and use it later (when I try it tells me no such file or directory)

    2 / Every time I have to include for each class but I learned that one can do include <QtGui> which should be sufficient

    3 / I use Qt 5.0.1 and every time I have to paste in the file. pro this
    "QT + = core gui
    GreaterThan (QT_MAJOR_VERSION 4): QT + = widgets "
    can I skip this task?

  • Moderators

    • You could install the headers and libs into system directories (or better, add to PATH), but for casual development I would not recommend this. In general you need to include the header, and add both header and source to your .pro file - if you are using qmake.
    • See above. QtGui is probably installed on your machine, and even if it's not qmake will add necessary includes when you run it. You can add some more automated includes, see QtSerialPort implementation for example (or use .pri files).
    • No, it's required as long as you are using qmake. You can shorten this line to
      QT += core gui widgets
      if you really want to and are using Qt5 only.

  • Thx for help...and i would like if u u make it clearer about the first question because i'm a beginner and i didn't try it at all

  • Moderators

    If you are a beginner, then just copy the files over to your new project and add them to .pro file. Then you can use them with a simple
    #include "mycopiedheader.h"

    Installing stuff globally or modifying qmake variables is a bit more hardcore.

Log in to reply