PDA

View Full Version : Cannot able to display the comports availability in the combobox



kulsekarr
22nd June 2012, 08:01
I am trying to display the comports availability in the system to be displayed in the combobox. it show some errors..
as shown below

D:\New Folder\untitled-build-desktop\..\untitled\mainwindow.cpp:35: error: undefined reference to `SerialDeviceEnumerator::instance()'

D:\New Folder\untitled-build-desktop\..\untitled\mainwindow.cpp:37: error: undefined reference to `SerialDeviceEnumerator::devicesAvailable() const'

I have used serialdeviceenumerator and abstract serial classes and i have attached my code also. kindly any one help me and replies are appreciated.

Untitled .h


#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtGui>
#include <QWidget>

#include <abstractserial.h>

class SerialDeviceEnumerator;
class AbstractSerial;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

private slots:
void on_comboBox_textChanged(const QStringList &arg1);
void initenum();

private:
Ui::MainWindow *ui;
SerialDeviceEnumerator *m_sde;
//AbstractSerial *serial;
QComboBox *cmbPorts;
QPushButton *start;

};


untitled.cpp


#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QtGui>
#include <QtCore/QDebug>
#include <QtCore/QStringList>

#include <iostream>
#include <serialdeviceenumerator.h>
#include <abstractserial.h>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);

initenum();


// this->m_sde = new SerialDeviceEnumerator(this);
// this->m_sde->setEnabled(true);

// QStringList devList = m_sde->devicesAvailable();

}

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

void MainWindow::initenum()
{
this->m_sde = SerialDeviceEnumerator::instance();
connect(this->m_sde, SIGNAL(QStringList)),this,SLOT(on_comboBox_textCha nged(QStringList)));
this->on_comboBox_textChanged(this->m_sde->devicesAvailable());
}


void MainWindow::on_comboBox_textChanged(const QStringList &arg1)
{
cmbPorts->clear();
cmbPorts->addItems(arg1);
}

Jonny174
22nd June 2012, 08:54
Uncheck option "Shadow Build" in QtCreator (if you build with it).
In .pro file HEADERS += serialdeviceenumerator.h abstractserial.h SOURCES += serialdeviceenumerator.cpp abstractserial.cpp

kulsekarr
22nd June 2012, 11:53
i have unchecked that shadow build option but still i couldn't get it.

ChrisW67
22nd June 2012, 12:04
Add the library containing the implementation of SerialDeviceEnumerator and AbstractSerial to your LIBS variable.