[Qt-interest] Accessing a class member from an operator
Oliver Heins
heins at sopos.org
Thu Apr 22 20:15:19 CEST 2010
John Weeks <john at wavemetrics.com> writes:
> On Apr 22, 2010, at 10:27 AM, Oliver Heins wrote:
>
>> I call the QDataStream &operator>> within Editor::readFile(). So
>> there
>> is an instance of Editor when the operator is called.
>
> But QDataStream &operator>> is not a member function, so it lacks the
> implied this-> pointer. It can't access member functions without
> explicit knowledge of the instance.
>
> I think the way you have declared QDataStream &operator>>, you must
> read it into an object of type Token. Then within readfile(), where
> you *do* have access to this-> for Editor, you would put the Token
> into partnerMap.
But the data I want to put in partnerMap is not of part of Token, but
just metadata needed for constructing a valid Token. So I guess I have
to make a class TmpToken, which holds this kind of data and will be
copied to Token within readfile().
I hoped I could circumvent this somehow.
Thanks,
olli
More information about the Qt-interest-old
mailing list