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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:32:28+00:00 2026-06-13T22:32:28+00:00

Coming from a C# background, I have some habbits that need to be changed.

  • 0

Coming from a C# background, I have some habbits that need to be changed. I’m tring to return a QList<int> from a function. The compiler error message is conversion from ‘QList*’ to non-scalar type ‘QList’ requested. Here is the function:

QList<int> toCategories(QVariant qv)
{
    QList<int>categories = new QList<int>();
    if(qv.isValid() && qv.type() == QVariant::List)
    {
        foreach(QVariant category,qv.toList()){
            categories.append(category.toInt() );
        }
    }
    return categories;
}

I’d appreciate a link to the documentation or a function using the correct syntax

  • 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-13T22:32:29+00:00Added an answer on June 13, 2026 at 10:32 pm

    The error is referring to the fact that you are attempting to covert between a non-pointer QList to a pointer to a QList. You need to either use a pointer to a QList as follows:

    QList<int>* toCategories(QVariant qv)
    {
        QList<int>* categories = new QList<int>();
        if(qv.isValid() && qv.type() == QVariant::List)
        {
            foreach(QVariant category,qv.toList()){
                categories->append(category.toInt() );
            }
            return categories;
        }
    }
    

    Alternately, you can use a non-pointer QList:

    QList<int> toCategories(QVariant qv)
    {
        QList<int> categories;
        if(qv.isValid() && qv.type() == QVariant::List)
        {
            foreach(QVariant category,qv.toList()){
                categories.append(category.toInt() );
            }
            return categories;
        }
    }
    

    Since you are new to C++, I would recommend reviewing this question.

    If I may also point out, your function as listed has a problem where a certain path doesn’t return a value (though I suspect that might be because you only copy-pasted a portion of your code).

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

Sidebar

Related Questions

Coming from a PHP background, I'm used to writing small functions that return a
I am coming from a Spring/hibernate background. I have noticed that Rails has no
So coming from a flash background I have an OK understanding of some simple
Coming from a UNIX background, with some knowledge of CVS and git, I have
I am coming from C# background and I have hard time figuring out how
Coming from a non-OO background in Matlab, I'm looking to perform some of the
I'm coming from a C++ background to python I have been declaring member variables
I'm coming from a c# background, and I do this: Console.Write(some text + integerValue);
Coming from a C++ background, I'm used to sticking the const keyword into function
I have read a bit about casting in C++. Coming from a C background,

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.