initilization of QScopedPointer
I have a empty QScopedPointer defined in a header.
Code:
QScopedPointer<HardwareInterface> hwi;
I know that I can initilize it doing this in my class.
Code:
MainClass
::MainClass(QObject *parent
) : QObject(parent
), hwi
(new HardwareInterface
()) {
}
But is there another way to do it in the main-line of the code? For example maybe I need to get the values of parameters before I init it.
I have tried this,
Code:
hwi = QScopedPointer<HardwareInterface>(new HardwareInterface());
but I get this error:
Code:
/home/trey/Qt5.2.1/5.2.1/gcc_64/include/QtCore/qglobal.h:979: error: 'QScopedPointer<T, Cleanup>& QScopedPointer<T, Cleanup>::operator=(const QScopedPointer<T, Cleanup>&) [with T = HardwareInterface; Cleanup = QScopedPointerDeleter<HardwareInterface>]' is private
Class &operator=(const Class &) Q_DECL_EQ_DELETE;
^
whatever that means.
Re: initilization of QScopedPointer
You can set the pointer after initialization using the reset method.
Re: initilization of QScopedPointer
Or use a QSharedPointer.
Cheers,
_
Re: initilization of QScopedPointer
thanks!
I guess I should of looked for something that took a pointer and returned a QScopedPointer.