Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Issue while I try to assign a QSharedPointer to a variable
Forum Updated to NodeBB v4.3 + New Features

Issue while I try to assign a QSharedPointer to a variable

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 588 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    beidaochuan
    wrote on last edited by
    #1

    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?

    ? 1 Reply Last reply
    0
    • B beidaochuan

      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?

      ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved