Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7998177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:08:54+00:00 2026-06-04T15:08:54+00:00

I would love to get a pointer to a QVector element so I can

  • 0

I would love to get a pointer to a QVector element so I can use that object elsewhere however the at() method gives me a const T& value and the operator[] gives me a T& value.

I’m confused on how to use these to get a pointer so that I will use the same object instead of using a copy constructor.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:08:55+00:00Added an answer on June 4, 2026 at 3:08 pm

    A T& value is not a copy, it is a reference.

    References look a lot like pointers : they are light, and can be used to modify the underlying object. Only, you use them with the same syntax as direct objects (with dots instead of arrows), and some other differences you may want to check out in the article.

    To edit an object currently inside the Vector, you can use for instance vector[i].action();. This will call the action() method from the object inside the vector, not on a copy. You can also hand over the reference to other functions (provided they take reference arguments), and they will still point to the same object.

    You can also get the adress of the object from a reference : Object* pObject = & vector[i]; and use it as any pointer.

    If you really need pointers to objects, you can also use a Vector of pointers : QVector<Object*> vector;
    However, this requires you to handle creation / destruction, which you don’t need with a Vector of objects.

    Now, if you want a pointer to the Vector itself, just do QVector<Object> *pVector = &vector;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would love to get some tips from other people that have had this
I would love to sort an embedded MongoDB object using PHP Lithium. I have
Working on a movie website and would love to find an API that I
my designer passed me a look that I would love to be able to
I would love to get some help with this. I'm using php and MySQL
I would love to get all the features lombok provides. I'm tired of writing
Some newbie questions. First, I would love to get this plugin: http://archive.plugins.jquery.com/project/getAttributes but I
I’m trying to reevaluate our n-layer architecture and would love to get some suggestions
Ok here's a little problem I would love to get some help on. I
I have design problem, which I would love to get a hand with. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.