I created a Qt project, using a barcode encoder/decoder library libzbarqt. When I added private *qr to mainwindow.h and initialized it by adding qr(new zbar::QZBar) to the MainWindow constructor, it didn't work.
Running it gives:
Starting /home/lily/program/qt/build-TestQZBar-Desktop-Debug/TestQZBar...
The program has unexpectedly finished.
/home/lily/program/qt/build-TestQZBar-Desktop-Debug/TestQZBar exited with code 0
Running a debugger gives a segmentation fault:
The inferior stopped because it received a signal from the Operating System.
Signal name :
SIGSEGV
Signal meaning :
Segmentation fault
Something went wrong by adding qr(new zvar::QZBar) to instantiate the pointer...
Missing something obvious...? Will appreciate any help or pointer. The project, header, cpp files, and running environment are as follows.
In TestQZBar.pro, added the line below:
unix:!macx: LIBS += -lzbarqt
====================mainwindow.h================== =====
ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <zbar/QZBar.h>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
zbar::QZBar *qr;
};
#endif // MAINWINDOW_H
================================================== =====
====================mainwindow.cpp================ =====
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
qr(new zbar::QZBar)
{
ui->setupUi(this);
qDebug() << "Testing QZBar\n";
/* if(qr->isVideoEnabled())
{
qDebug() << "Video is enabled.\n";
} else {
qDebug() << "Video is disabled.\n";
}
*/
}
MainWindow::~MainWindow()
{
delete ui;
}
================================================== =====
Environment:
Qt Creator 2.7.1 Based on Qt 5.0.2 (64 bit)
OS is Ubuntu 13.04
Installed libzbarqt-dev (ver.0.10+doc-8)
Bookmarks