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. QSerialPortInfo undefined Type
QtWS25 Last Chance

QSerialPortInfo undefined Type

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 761 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.
  • G Offline
    G Offline
    Gh0stShell
    wrote on last edited by
    #1

    Hi,

    I try to use QSerialPortInfo, but I get the Issue that QSerialPortInfo is an undefined tpye.

    Q_FOREACH(QSerialPortInfo port, QSerialPortInfo::availablePorts()) {
        qDebug() << "Port: " << port.portName();
    }
    

    Yes, I added serialport qo the .pro

    Any Ideas why it doesn't work?

    JonBJ 1 Reply Last reply
    0
    • G Gh0stShell

      Hi,

      I try to use QSerialPortInfo, but I get the Issue that QSerialPortInfo is an undefined tpye.

      Q_FOREACH(QSerialPortInfo port, QSerialPortInfo::availablePorts()) {
          qDebug() << "Port: " << port.portName();
      }
      

      Yes, I added serialport qo the .pro

      Any Ideas why it doesn't work?

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @Gh0stShell
      Do you mean that you failed to #include <QSerialPortInfo> into your source file? "undefined tpye" at compile or at link time?

      G 1 Reply Last reply
      2
      • M Offline
        M Offline
        macfanpl
        wrote on last edited by
        #3

        Even when someone forgets about include directive, qt IDE should autoadd respective include directive.

        JonBJ Pablo J. RoginaP 2 Replies Last reply
        0
        • M macfanpl

          Even when someone forgets about include directive, qt IDE should autoadd respective include directive.

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @macfanpl said in QSerialPortInfo undefined Type:

          Even when someone forgets about include directive, qt IDE should autoadd respective include directive.

          Since when?

          1 Reply Last reply
          0
          • M macfanpl

            Even when someone forgets about include directive, qt IDE should autoadd respective include directive.

            Pablo J. RoginaP Offline
            Pablo J. RoginaP Offline
            Pablo J. Rogina
            wrote on last edited by Pablo J. Rogina
            #5

            @macfanpl said in QSerialPortInfo undefined Type:

            qt IDE should autoadd respective include directive.

            And please tell us how Qt Creator will know what include directive to use?

            Let's say that I wrote a super-duper serial port information class that coincidentally is named QSerialPortInfo BUT I decided my .h file to be named SerialComms... so what Qt Creator will do?

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • JonBJ JonB

              @Gh0stShell
              Do you mean that you failed to #include <QSerialPortInfo> into your source file? "undefined tpye" at compile or at link time?

              G Offline
              G Offline
              Gh0stShell
              wrote on last edited by Gh0stShell
              #6

              @JonB Yes, I really forgot to #include <QSerialPortInfo>. But as @macfanpl said Qt automatically added it.

              But it was a good help to see what the problem is. Qt autoadded it like #include <QtSerialPort/QSerialPort>.
              I did split it up to
              #include <QtSerialPort>
              and
              #include <QSerialPort>
              and now it seems to work. So the Problem was a mix of me forgetting to import and Qt to import it not the right way. I think...

              Thank you

              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