This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Use Serial port on Qt

Hi

I am working with emv-sk and want to use the serial port on my Qt program but it seems that Qt can not find the libs.

I can Run any simple gui with out using libraries but as soon as I add serial I get this error:

" error: undefined reference to `QSerialPort::QSerialPort(QObject*)'"

here is my project file

QT  += core gui webkit serialport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport

#CONFIG += serialport

TARGET = terminal
TEMPLATE = app

SOURCES += main.cpp\
        terminal.cpp \
    keyboard/keyboard.cpp \
    qcustomplot.cpp \
    serialportfactory.cpp

HEADERS  += terminal.h \
    keyboard/keyboard.h \
    keyboard/ui_keyboard.h \
    qcustomplot.h \
    serialportfactory.h

FORMS    += terminal.ui \
    keyboard/keyboard.ui

    target.path += /home/root
    INSTALLS += target

and  here is terminal.cpp

#include "terminal.h"
#include "ui_terminal.h"
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QtGui>
#include "AnalogWidgets/analogwidgets/analogwidgets/chart.h"
#include "AnalogWidgets/analogwidgets/analogwidgets/chart/datacontainers.h"

//QSerialPort ComPort;
terminal::terminal(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::terminal)
{
    ui->setupUi(this);
    lineEditkeyboard = new Keyboard();
    connect( ui->lineEdit_commandline ,SIGNAL(selectionChanged()),this ,SLOT(open_keyboard_lineEdit()));
  //  QSerialPort *serial;
 //  serial = new QSerialPort();
    /*
    serial.setPortName("com1");
    serial.setBaudRate(QSerialPort::Baud9600);
    serial.setDataBits(QSerialPort::Data8);
    serial.setParity(QSerialPort::NoParity);
    serial.setStopBits(QSerialPort::OneStop);
    serial.setFlowControl(QSerialPort::NoFlowControl);
    serial.open(QIODevice::ReadWrite);
    serial.write("firs string to serial");
    serial.close();
*/
     // Layout of - chart
    //QWidget * widget = tabWidget->widget(0);
  /*  chart = new Chart();
    QLayout * layout3 = new QVBoxLayout();
    layout3->addWidget(chart);
    QLayout * wert = new QHBoxLayout();
    wert->addWidget(chartPosition);
    wert->addWidget(zoomBox);
    layout3->addItem(wert);
    layout3->addWidget(sizeSlider);
    layout3->addWidget(injCombo);
    widget->setLayout(layout3);
*/

}

terminal::~terminal()
{
    delete ui;
}

void terminal::on_Bt_Exit_clicked()
{
    qApp->quit();
}

I also tried to use linux terminal:

[linux-devkit]:~/Temp/terminal> qmake terminal.pro
Project MESSAGE: Warning: unknown QT: serialport

seems that it can not do QT += serialport

here are the versions:

[linux-devkit]:~/Temp/terminal> qmake -v
QMake version 2.01a
Using Qt version 4.8.4 in /home/ramin/ti-sdk-7/linux-devkit/sysroots/cortexa8hf-vfp-neon-3.8-oe-linux-gnueabi/usr/lib

[linux-devkit]:~/Temp/terminal> moc -v
Qt Meta Object Compiler version 63 (Qt 4.8.4)

Thanks

Ramin