Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [Solved]: Implementing an abstract class within an qt-creator project
Forum Updated to NodeBB v4.3 + New Features

[Solved]: Implementing an abstract class within an qt-creator project

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
10 Posts 3 Posters 1.2k Views 1 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.
  • A Offline
    A Offline
    andi456
    wrote on last edited by andi456
    #1

    Hi,

    to plot a smoother mathematical curve with qwt using qt-creator, as the default doesn't look really good, the qwt-developer pointed me to QwtSyntheticPointData

    which is an abstract class. But I have not been able to figure out, how I could integrate it into a standard qt-creator project. Obviously I need write my own class based on the abstract one. But how do I do that within a qt-creator project?

    Thanks in advance,

    Kind regards,

    Andreas

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

      Hi,

      Qt Creator provides a wizard to add new classes to your project.

      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
      2
      • A Offline
        A Offline
        andi456
        wrote on last edited by
        #3

        Thanks, I'll look into that this evening and report back

        Kind regards,

        Andreas

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andi456
          wrote on last edited by
          #4

          Finally, i found the time to search for the class wizard, but i have been unable to find it in the german version of qt creator. Do i need to add it somehow or configure qt creator in a certain way?

          Isn't there some kind of tutorial to add a class to an existing project "by hand"? It is difficult to find something like that on the internet, as there are too many results, when searching for rather generic keywords.

          J.HilkJ 1 Reply Last reply
          0
          • A andi456

            Finally, i found the time to search for the class wizard, but i have been unable to find it in the german version of qt creator. Do i need to add it somehow or configure qt creator in a certain way?

            Isn't there some kind of tutorial to add a class to an existing project "by hand"? It is difficult to find something like that on the internet, as there are too many results, when searching for rather generic keywords.

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @andi456 right mouse button on over all project folder, -> "Hinzufügen" -> C++ -> C++ Klasse


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply
            2
            • A Offline
              A Offline
              andi456
              wrote on last edited by
              #6

              Thanks, it's sometimes hard to get used to all the functions of an IDE. Unfortunately, this led me only back to the problem, that i was hoping solve anyway. I've got the empty header and empty source file, and the IDE or compiler tells me the following:

              "Error constructor for 'WageCurvePoints' must explicitly initialize the base class 'QwtSyntheticPointData' which does not have a default constructor"

              I haven't been able to figure out how to accomplish the initialization of the base class. I tried to adapt the example given in the source code of 'QwtSyntheticPointData', but couldn't make it work....

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

                Can you show the code you have ?

                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
                • A Offline
                  A Offline
                  andi456
                  wrote on last edited by andi456
                  #8

                  Sure, as i said, i just tried to implement the simple sine example of the man page of QwtSyntheticPointData so the name WageCurvePoints is a little misleading. The problem seems to be that there is no header file in the example. So this is, what i put in the header file:

                  #ifndef WAGECURVEPOINTS_H
                  #define WAGECURVEPOINTS_H
                  #include "qwt6/qwt_point_data.h"

                  class WageCurvePoints : public QwtSyntheticPointData
                  {
                  public:
                  WageCurvePoints():
                  QwtSyntheticPointData( 100 )
                  {
                  }

                  virtual double y( double x ) const
                  {
                      return qSin( x );
                  }
                  

                  };

                  #endif // WAGECURVEPOINTS_H

                  In the cpp file there's nothing more than that, what the wizard created resulting in the above error message:

                  #include "wagecurvepoints.h"

                  WageCurvePoints::WageCurvePoints()
                  {

                  };

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

                    Well, you have two different implementations of the same constructor. Either remove the one from the .cpp file or move the one from your header and replace the version you have in the .cpp.

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

                    A 1 Reply Last reply
                    2
                    • SGaistS SGaist

                      Well, you have two different implementations of the same constructor. Either remove the one from the .cpp file or move the one from your header and replace the version you have in the .cpp.

                      A Offline
                      A Offline
                      andi456
                      wrote on last edited by
                      #10

                      @SGaist : Thanks again, it worked by putting all the code into the header file. I could not figure out which way would be more "correct".

                      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