error: 'QObject& QObject::operator=(const QObject)' is private 問題解決

今天QT編程時遇到了這樣的問題:

/opt/QtEmbedded-4.7.3/include/QtCore/qobject.h:309: error: ‘QObject& QObject::operator=(const QObject&)’ is private

/opt/QZXing/QZXing.h:28: error: within this context

弄了一會才明白是我構建對象時出了問題,我的構建過程如下:

QZXing decoder;
decoder = QZXing(QZXing::DecoderFormat_QR_CODE);

正確過程應該是:

QZXing *decoder;
decoder = new QZXing(QZXing::DecoderFormat_QR_CODE);

或者

QZXing decoder(QZXing::DecoderFormat_QR_CODE);

原因在於QZXing這個類是繼承了QObject類的,而QObject不允許通過"="操作符進行對象複製。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章