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 7079411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:40:09+00:00 2026-05-28T06:40:09+00:00

This one is a little strange to me. I have a pointer to a

  • 0

This one is a little strange to me.

I have a pointer to a class member (mGeometry), which, in turn, holds a pointer to a QList< GLushort > data member (mFaces). I am trying to get the index of mFaces via the class Cube.

So, the more simplified version would look like this:

struct Geometry
{   
    Geometry( void );
    ~Geometry( void );
    void someFunc( void );
    QList< GLushort > *mFaces;
};

class Cube
{   
 public:
    Cube( void );
    ~Cube( void );
    void anotherFunc( void );
    Geometry *mGeometry;
};

Let’s say, in anotherFunc, we’re trying to do the following:

GLushort *indeces = new GLushort;

*indeces = ( *mGeometry ).mFaces[ 0 ];

Error(s)

error: cannot convert ‘QList<short unsigned int>’ to ‘GLushort {aka short unsigned int}’ in assignment

So, we try:

*indeces = mGeometry->( *mFaces )[ 0 ]; //which, is originally how I've accessed pointers-to-containers' indexes.

Error(s)

error: expected unqualified-id before ‘(’ token

error: ‘mFaces’ was not declared in this scope

And, of course, the obvious:

*indeces =  mGeometry->mFaces[ 0 ];

Error(s)

error: cannot convert ‘QList<short unsigned int>’ to ‘GLushort {aka short unsigned int}’ in assignment

Constructor for Geometry

Geometry::Geometry( void )
    : mFaces( new QList< GLushort > )
{
}

Is there anything wrong I’m doing here? If not, what is the correct method to obtain the index of the pointer to mFaces?

  • 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-05-28T06:40:09+00:00Added an answer on May 28, 2026 at 6:40 am

    Because mFaces is a pointer, you have to dereference mGeometry with -> then dereference mFaces with * then use QList<>‘s operator[] to get the number:

    *indeces = (*mGeometry->mFaces)[0]; // note that * has lower precedence than ->
                                        // so this is like (*(mGeometry->mFaces))[0]
    

    It’s a little weird because [0] does the same thing as *. Indices on pointer types, such as x[i], follow the formula *(x + i), so you can also do this for the same effect (but don’t):

    *indeces = mGeometry->mFaces[0][0]; // or *indeces = (*mGeometry).mFaces[0][0];
    

    Which is the same as (*(mFaces + 0))[0], which is exactly the same as (*mFaces)[0].

    That is also why you got that error cannot convert ‘QList<short unsigned int>’ to ‘GLushort’ when you tried to do

    ( *mGeometry ).mFaces[ 0 ];
    

    Because ( *mGeometry ).mFaces[ 0 ]; (which, again, is equivalent to the above *mGeometry->mFaces) gets you a QList<GLushort>, and you have to use the operator[] of QList<> to get your data.

    And now for something completely unrelated, you misspelled indices 🙂

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

Sidebar

Related Questions

OK it's little strange for me. I never used something like this. I have
Hello fellow developers, I am a little stumped on this one as I have
This one might be a little confusing. I'm using AMCharts with rails. Amcharts comes
This is one of those little detail (and possibly religious) questions. Let's assume we're
This one has proven to be a little tricky for me so far. I
I'm a little stumped on this one and I'm also not still on 1.8
Nasty little bug, this one. As illustrated in Android ticket 6721 , the Android
Why only one overload throws this exception? Little update: I understand that there was
I want to write a class which provides basically a list of entries. This
Bit of a strange one here, i have a CCTV system and contacted the

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.