Important: Please read the Qt Code of Conduct -

Issue while I try to assign a QSharedPointer to a variable

  • Hello,
    I make some as follows.

      QSharedPointer<User> pointer(new User());
      // UserSettings is a Class
      const UserSettings &userSettingsRef = pointer; 

    Complie error should happen, but it not.
    Could somebody tell me why?

  • Hi! This gives me the following compile error:

    invalid initialization of reference of type 'const UserSettings&' from expression of type 'QSharedPointer<User>'
         const UserSettings &userSettingsRef = pointer;

    What's your platform / compiler?

Log in to reply