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. Can I use QSerialPort class on C not C++?
Forum Updated to NodeBB v4.3 + New Features

Can I use QSerialPort class on C not C++?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 1.9k 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.
  • J Offline
    J Offline
    Jaeheon Chung
    wrote on last edited by
    #1

    if it can, how to?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      Yes you can.
      You need to create a wrapper C library that will hide all C++ and provide C interface to the classes. You need to create an init() function that will initialize Qt and then provide openSerial(), readSerial(), closeSerial(), and whatever other functions you need.
      Don't forget to use
      @
      extern "C" {
      }
      @
      around your C functions.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jaeheon Chung
        wrote on last edited by
        #3

        Thank you andreyc,

        But I want to know method to use Qt library on C.

        When I use your recommended method, it works well?

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          Use QLibrary class

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • jensen82J Offline
            jensen82J Offline
            jensen82
            wrote on last edited by
            #5

            @Dheerendra: You should read the question and not just answer to collect points.

            1 Reply Last reply
            0
            • dheerendraD Offline
              dheerendraD Offline
              dheerendra
              Qt Champions 2022
              wrote on last edited by
              #6

              hmm. Thank your comment. Sorry if you have misinterpreted the question. I took the question other way around.

              Now coming to points does not help me any way. I'm not here for points. I'm spending my personal time here without any gains. I here to help the people with my knowledge. If you have admin capability request you to set all my points to zero.

              I'm here to get my Qt knowledge enlightened. Nothing more than.

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              1 Reply Last reply
              0
              • jensen82J Offline
                jensen82J Offline
                jensen82
                wrote on last edited by
                #7

                @Dheerendra: It's ok. It was a bit hard from me, sorry for that. If you got your knowledge "enlightened" you hit the target. Have a nice day.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andreyc
                  wrote on last edited by
                  #8

                  [quote author="jaeheon" date="1404960344"]But I want to know method to use Qt library on C.[/quote]
                  Out of curiosity, why do you need to use Qt in C project?

                  [quote]When I use your recommended method, it works well?[/quote]
                  It should work. There is nothing special about Qt here. It is a way to provide a C API to C++ library. I used it but not with Qt.
                  I would not recommend to provide full Qt API through C API only a part that you need for your project.

                  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