Results 1 to 4 of 4

Thread: Cannot able to display the comports availability in the combobox

  1. #1
    Join Date
    Dec 2011
    Location
    Bangalore,India
    Posts
    38
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Cannot able to display the comports availability in the combobox

    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

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5. #include <QtGui>
    6. #include <QWidget>
    7.  
    8. #include <abstractserial.h>
    9.  
    10. class SerialDeviceEnumerator;
    11. class AbstractSerial;
    12.  
    13. namespace Ui {
    14. class MainWindow;
    15. }
    16.  
    17. class MainWindow : public QMainWindow
    18. {
    19. Q_OBJECT
    20.  
    21. public:
    22. explicit MainWindow(QWidget *parent = 0);
    23. ~MainWindow();
    24.  
    25. private slots:
    26. void on_comboBox_textChanged(const QStringList &arg1);
    27. void initenum();
    28.  
    29. private:
    30. Ui::MainWindow *ui;
    31. SerialDeviceEnumerator *m_sde;
    32. //AbstractSerial *serial;
    33. QComboBox *cmbPorts;
    34. QPushButton *start;
    35.  
    36. };
    To copy to clipboard, switch view to plain text mode 

    untitled.cpp

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. #include <QtGui>
    5. #include <QtCore/QDebug>
    6. #include <QtCore/QStringList>
    7.  
    8. #include <iostream>
    9. #include <serialdeviceenumerator.h>
    10. #include <abstractserial.h>
    11.  
    12. MainWindow::MainWindow(QWidget *parent) :
    13. QMainWindow(parent),
    14. ui(new Ui::MainWindow)
    15. {
    16. ui->setupUi(this);
    17.  
    18. initenum();
    19.  
    20.  
    21. // this->m_sde = new SerialDeviceEnumerator(this);
    22. // this->m_sde->setEnabled(true);
    23.  
    24. // QStringList devList = m_sde->devicesAvailable();
    25.  
    26. }
    27.  
    28. MainWindow::~MainWindow()
    29. {
    30. delete ui;
    31. }
    32.  
    33. void MainWindow::initenum()
    34. {
    35. this->m_sde = SerialDeviceEnumerator::instance();
    36. connect(this->m_sde, SIGNAL(QStringList)),this,SLOT(on_comboBox_textChanged(QStringList)));
    37. this->on_comboBox_textChanged(this->m_sde->devicesAvailable());
    38. }
    39.  
    40.  
    41. void MainWindow::on_comboBox_textChanged(const QStringList &arg1)
    42. {
    43. cmbPorts->clear();
    44. cmbPorts->addItems(arg1);
    45. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 24th June 2012 at 14:02. Reason: missing [code] tags

  2. #2
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Cannot able to display the comports availability in the combobox

    Uncheck option "Shadow Build" in QtCreator (if you build with it).
    In .pro file HEADERS += serialdeviceenumerator.h abstractserial.h SOURCES += serialdeviceenumerator.cpp abstractserial.cpp

  3. #3
    Join Date
    Dec 2011
    Location
    Bangalore,India
    Posts
    38
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot able to display the comports availability in the combobox

    i have unchecked that shadow build option but still i couldn't get it.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Cannot able to display the comports availability in the combobox

    Add the library containing the implementation of SerialDeviceEnumerator and AbstractSerial to your LIBS variable.

Similar Threads

  1. Replies: 1
    Last Post: 26th March 2011, 05:31
  2. Help ComboBox
    By vinny gracindo in forum Newbie
    Replies: 3
    Last Post: 20th November 2009, 20:41
  3. Checking network availability
    By fullmetalcoder in forum Qt Programming
    Replies: 2
    Last Post: 10th March 2008, 20:23
  4. ComboBox of bmp:s
    By SailinShoes in forum Qt Programming
    Replies: 2
    Last Post: 5th March 2008, 16:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.