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. What extra things to do when c based file to add in qt and when we want to add QString class in it ?
Forum Updated to NodeBB v4.3 + New Features

What extra things to do when c based file to add in qt and when we want to add QString class in it ?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 410 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.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by Qt embedded developer
    #1

    Actually main problem is i want to use QString in c file .

    i have added NFC interface related set of files written in in c in qt. to support nfc interface i have added that. Now i want to use QString class in that file. then how to use it ?

    because when i add below code in same file than it give lots of error:
    " error: unknown type name 'class' class QString"

    My added header file is

    #include <QString>

    & written code is :

     static char filename[20];
      static int adapter_nr = 2;
    
      QString status = QString("/dev/i2c-%1").arg(adapter_nr);
    
    
    jsulmJ 1 Reply Last reply
    0
    • J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #5

      then that way is not possible.

      You can incorporate c files/code in a c++ project or you can include a c++ library(precompiled) in a c project but you can't s imply include c++ code into a c project.


      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
      3
      • Q Qt embedded developer

        Actually main problem is i want to use QString in c file .

        i have added NFC interface related set of files written in in c in qt. to support nfc interface i have added that. Now i want to use QString class in that file. then how to use it ?

        because when i add below code in same file than it give lots of error:
        " error: unknown type name 'class' class QString"

        My added header file is

        #include <QString>

        & written code is :

         static char filename[20];
          static int adapter_nr = 2;
        
          QString status = QString("/dev/i2c-%1").arg(adapter_nr);
        
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @Qt-embedded-developer said in What extra things to do when c based file to add in qt and when we want to add QString class in it ?:

        i want to use QString in c file

        Then it needs to be C++ file.
        What is file extension? .c or .cpp?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        Q 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Qt-embedded-developer said in What extra things to do when c based file to add in qt and when we want to add QString class in it ?:

          i want to use QString in c file

          Then it needs to be C++ file.
          What is file extension? .c or .cpp?

          Q Offline
          Q Offline
          Qt embedded developer
          wrote on last edited by
          #3

          @jsulm File extension is '.c'

          jsulmJ 1 Reply Last reply
          0
          • Q Qt embedded developer

            @jsulm File extension is '.c'

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @Qt-embedded-developer Change to .cpp

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2
            • J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #5

              then that way is not possible.

              You can incorporate c files/code in a c++ project or you can include a c++ library(precompiled) in a c project but you can't s imply include c++ code into a c project.


              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
              3

              • Login

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