[Qt-interest] QPointer usage

Prashanth Udupa prashanthudupa at yahoo.com
Sun Aug 30 14:18:18 CEST 2009


Hi,

As the documentation says QPointer can only be used with subclasses of QObject, which QString is not.

HTH.

/ Prashanth




________________________________
From: Patric <userqt at gmail.com>
To: qt-interest at trolltech.com
Sent: Sunday, August 30, 2009 4:35:54 PM
Subject: [Qt-interest] QPointer usage

 
Hello, 
I'm trying to assign a normal pointer to QPointer 
instance. But there is an error 
 
c:/Qt/2009.03/qt/include/QtCore/../../src/corelib/kernel/qpointer.h: 
In member function `QPointer<T>& QPointer<T>::operator=(T*) 
[with T = QString]': 
main.cpp:16: instantiated from here
c:/Qt/2009.03/qt/include/QtCore/../../src/corelib/kernel/qpointer.h:68: 
error: comparison between distinct pointer types `QObject*' and `QString*' lacks 
a cast
c:/Qt/2009.03/qt/include/QtCore/../../src/corelib/kernel/qpointer.h:68: 
error: no matching function for call to `QMetaObject::changeGuard(QObject**, 
QString*&)'
c:/Qt/2009.03/qt/include/QtCore/../../src/corelib/kernel/qobjectdefs.h:340: 
note: candidates are: static void QMetaObject::changeGuard(QObject**, 
QObject*)
 
Here is the code 
 
QString *string = new QString();QPointer<QString> 
pointer;
pointer 
= string;
 
 
Why it's not working ? 
 
Regards, 
Patric


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090830/b7ebb1ef/attachment.html 


More information about the Qt-interest-old mailing list