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. Loss of include files
Forum Updated to NodeBB v4.3 + New Features

Loss of include files

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 354 Views 2 Watching
  • 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.
  • M Offline
    M Offline
    Mark K R Walker
    wrote on last edited by
    #1

    I'm still new to Qt Creator although I will claim some progress.
    I am trying to add sound to my project which is a CW trainer for the Farnsworth method.

    To this end, I have added a header and source file and I have written a little code. My problem is that when I add the "#include" for the header file in the source file, the combination will not compile and some of the "#include" libraries are lost. That is, the message "no such file or directory" is issued.
    I have tried to add the appropriate #includde moc_???.cpp but this doesn't seem to fix the problem. An attempt is made to produce the relevent cpp file but it is empty.

    The little bits of code follow
    Sound.h...
    #ifndef SOUND_H
    #define SOUND_H
    //#include <QAudioSink>
    #include <QByteArray>
    #include <QIODevice>
    #include <QMediaDevices>
    #include <QObject>
    #include <QTimer>
    #include <QAudioDevice>
    class Sound : public QIODevice
    {
    Q_OBJECT

    private:
    QMediaDevices *AllMediaDevices = nullpointer;
    QAudioDevice DefaultAudioOutputDevice;

    public:
    Sound();

    #endif // SOUND_H

    and the source file, Sound.cpp contents...

    #include "Sound.h"
    //#include <QAudioDevice>
    //#include <QAudioSink>
    #include <QDebug>
    #include <QtEndian>
    #include <QtMath>
    Sound::Sound(){
    AllMediaDevices = new QMediaDevices(this);
    DefaultAudioOutputDevice = AllMediaDevices->defaultAudioOutput();
    }
    #include "moc_Sound.cpp"

    Would some kind person tell me where I'm going wrong.

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

      Hi,

      Which errors are you getting exactly ?
      Did you add these files to your CMakeLists.txt or .pro file ?

      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
      1
      • M Mark K R Walker

        I'm still new to Qt Creator although I will claim some progress.
        I am trying to add sound to my project which is a CW trainer for the Farnsworth method.

        To this end, I have added a header and source file and I have written a little code. My problem is that when I add the "#include" for the header file in the source file, the combination will not compile and some of the "#include" libraries are lost. That is, the message "no such file or directory" is issued.
        I have tried to add the appropriate #includde moc_???.cpp but this doesn't seem to fix the problem. An attempt is made to produce the relevent cpp file but it is empty.

        The little bits of code follow
        Sound.h...
        #ifndef SOUND_H
        #define SOUND_H
        //#include <QAudioSink>
        #include <QByteArray>
        #include <QIODevice>
        #include <QMediaDevices>
        #include <QObject>
        #include <QTimer>
        #include <QAudioDevice>
        class Sound : public QIODevice
        {
        Q_OBJECT

        private:
        QMediaDevices *AllMediaDevices = nullpointer;
        QAudioDevice DefaultAudioOutputDevice;

        public:
        Sound();

        #endif // SOUND_H

        and the source file, Sound.cpp contents...

        #include "Sound.h"
        //#include <QAudioDevice>
        //#include <QAudioSink>
        #include <QDebug>
        #include <QtEndian>
        #include <QtMath>
        Sound::Sound(){
        AllMediaDevices = new QMediaDevices(this);
        DefaultAudioOutputDevice = AllMediaDevices->defaultAudioOutput();
        }
        #include "moc_Sound.cpp"

        Would some kind person tell me where I'm going wrong.

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #3

        @Mark-K-R-Walker

        As @SGaist mentioned above, it seems like you've created the files manually in your filesystem without adding them to your project.
        Check your project configuration and make sure all sources are listed in either your YourProject.pro or your CMakeLists.txt file.
        Usually you don't need to include moc files by hand unless you have a headerless (e.g. main.cpp only) program and you declare/define QObject classes in your source files.


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        M 1 Reply Last reply
        1
        • Pl45m4P Pl45m4

          @Mark-K-R-Walker

          As @SGaist mentioned above, it seems like you've created the files manually in your filesystem without adding them to your project.
          Check your project configuration and make sure all sources are listed in either your YourProject.pro or your CMakeLists.txt file.
          Usually you don't need to include moc files by hand unless you have a headerless (e.g. main.cpp only) program and you declare/define QObject classes in your source files.

          M Offline
          M Offline
          Mark K R Walker
          wrote on last edited by
          #4

          @Pl45m4
          Thank you so much for replying.

          Yes, the files have been added to the project in my cwtrainer.pro.
          In following your advice, I noticed that my QT "Setting" in my cwtrainer.pro file is
          QT += core gui
          which seems correct since I have largely completed the GUI for cwtrainer.
          I have noticed in a couple of examples which I have looked at concerning producing the sound and which I can compile and run, the setting of the QT entry is
          QT += multimedia widgets
          These examples also have rudimentary GUIs so I have tried to add a multimedia widgets entry. I've tried just adding the above line to give,
          QT += core gui
          QT += multimedia widgets
          This gives rise to a huge number of problems.
          I've also tried replacing the QT += core gui by the line QT += multimedia widgets. This gives me a whole list of issues also.
          Is there a way of changing the setting of the QT entry to accommodate both the core gui and multimedia widgets settings since it seems that such a solution will resolve my problem

          I've looked in the documentation but I cant seem to find an answer.
          Thanks in advance.

          Pl45m4P 1 Reply Last reply
          0
          • M Mark K R Walker

            @Pl45m4
            Thank you so much for replying.

            Yes, the files have been added to the project in my cwtrainer.pro.
            In following your advice, I noticed that my QT "Setting" in my cwtrainer.pro file is
            QT += core gui
            which seems correct since I have largely completed the GUI for cwtrainer.
            I have noticed in a couple of examples which I have looked at concerning producing the sound and which I can compile and run, the setting of the QT entry is
            QT += multimedia widgets
            These examples also have rudimentary GUIs so I have tried to add a multimedia widgets entry. I've tried just adding the above line to give,
            QT += core gui
            QT += multimedia widgets
            This gives rise to a huge number of problems.
            I've also tried replacing the QT += core gui by the line QT += multimedia widgets. This gives me a whole list of issues also.
            Is there a way of changing the setting of the QT entry to accommodate both the core gui and multimedia widgets settings since it seems that such a solution will resolve my problem

            I've looked in the documentation but I cant seem to find an answer.
            Thanks in advance.

            Pl45m4P Offline
            Pl45m4P Offline
            Pl45m4
            wrote on last edited by Pl45m4
            #5

            @Mark-K-R-Walker said in Loss of include files:

            Is there a way of changing the setting of the QT entry to accommodate both the core gui and multimedia widgets settings since it seems that such a solution will resolve my problem

            It concatenates.
            So it's

            QT += core gui widgets multimedia
            

            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            1 Reply Last reply
            0
            • aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by aha_1980
              #6

              @Mark-K-R-Walker

              If your header really looks like you showed us, it's no wonder you get compile errors:

              #ifndef SOUND_H
              #define SOUND_H
              ...
              class Sound : public QIODevice
              {
              Q_OBJECT
              private:
                  QMediaDevices *AllMediaDevices = nullpointer;
                  QAudioDevice DefaultAudioOutputDevice;
              public:
                  Sound();
              }; // <- Closing curly brace and semicolon are missing!
              
              #endif // SOUND_H
              

              Please add the }; before the #endif and try again.

              Regards

              Qt has to stay free or it will die.

              1 Reply Last reply
              1

              • Login

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