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. How can I test out header files and related C++ source code?

How can I test out header files and related C++ source code?

Scheduled Pinned Locked Moved General and Desktop
headerheader cpp qt
4 Posts 3 Posters 2.0k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on 27 Jul 2015, 07:01 last edited by A Former User
    #1

    I try to add new function for my Qt program with CPP and header file. But I'm not quite sure if I get it right. Like to test it out on Qt Creator, but errors and warnings keeps popping up. I don't know what I I've done wrong.

    header:

    #include <QApplication>
    #include <QObject>
    #include <QWidget>
    #include <QString>
    #include <iostream>

    #ifndef TEST_H
    #define TEST_H

    class test{
    public:
    static bool check(const QString& data);
    static void run;
    public:
    static unsigned char* pTr = NULL;
    }

    J 1 Reply Last reply 27 Jul 2015, 11:50
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 27 Jul 2015, 08:41 last edited by
      #2

      Hi and welcome.

      I added some comment to the code to show the changes to make it compile.

      I wonder if you are aware of using static in classes has a completely other meaning than
      in good old C.
      http://www.tutorialspoint.com/cplusplus/cpp_static_members.htm
      :)

      #ifndef TEST_H
      #define TEST_H
      class test{
      public:
      static bool check(const QString& data);
      static void run(); <------------- must have () when function
      public:
      static unsigned char* pTr = NULL;
      }; <---- must end with ;
      #endif <----- was missing
      
      ? 1 Reply Last reply 28 Jul 2015, 01:20
      0
      • ? A Former User
        27 Jul 2015, 07:01

        I try to add new function for my Qt program with CPP and header file. But I'm not quite sure if I get it right. Like to test it out on Qt Creator, but errors and warnings keeps popping up. I don't know what I I've done wrong.

        header:

        #include <QApplication>
        #include <QObject>
        #include <QWidget>
        #include <QString>
        #include <iostream>

        #ifndef TEST_H
        #define TEST_H

        class test{
        public:
        static bool check(const QString& data);
        static void run;
        public:
        static unsigned char* pTr = NULL;
        }

        J Offline
        J Offline
        JKSH
        Moderators
        wrote on 27 Jul 2015, 11:50 last edited by
        #3

        @rogerloh4.0 said:

        errors and warnings keeps popping up. I don't know what I I've done wrong.

        Read the error messages. They tell you what's wrong.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        0
        • M mrjj
          27 Jul 2015, 08:41

          Hi and welcome.

          I added some comment to the code to show the changes to make it compile.

          I wonder if you are aware of using static in classes has a completely other meaning than
          in good old C.
          http://www.tutorialspoint.com/cplusplus/cpp_static_members.htm
          :)

          #ifndef TEST_H
          #define TEST_H
          class test{
          public:
          static bool check(const QString& data);
          static void run(); <------------- must have () when function
          public:
          static unsigned char* pTr = NULL;
          }; <---- must end with ;
          #endif <----- was missing
          
          ? Offline
          ? Offline
          A Former User
          wrote on 28 Jul 2015, 01:20 last edited by
          #4

          @mrjj No, I didn't know that, thanks for pointing my errors out. :)

          1 Reply Last reply
          0

          2/4

          27 Jul 2015, 08:41

          • Login

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