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. How to init: QList <type> * list;

How to init: QList <type> * list;

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.3k Views
  • 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.
  • Hanna LarssonH Offline
    Hanna LarssonH Offline
    Hanna Larsson
    wrote on last edited by Hanna Larsson
    #1

    Hi, I have a Qlist:

    QList <QHBoxLayout*> *listOfFieldLayouts;
    

    that I want to initialize in the constructor. I tried doing this:

    listOfFieldLayouts = new QList <QHBoxLayout*>();
    

    but it says that they don't match, because of a pointer like this:

    (operand types are 'QList<QHBoxLayout*>' and 'QList<QHBoxLayout*>*')

    How do I make them match?

    Hanna

    Bonjour!

    raven-worxR 1 Reply Last reply
    0
    • Hanna LarssonH Hanna Larsson

      Hi, I have a Qlist:

      QList <QHBoxLayout*> *listOfFieldLayouts;
      

      that I want to initialize in the constructor. I tried doing this:

      listOfFieldLayouts = new QList <QHBoxLayout*>();
      

      but it says that they don't match, because of a pointer like this:

      (operand types are 'QList<QHBoxLayout*>' and 'QList<QHBoxLayout*>*')

      How do I make them match?

      Hanna

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Hanna-Larsson
      this code looks actually correct.
      Can you post the exact error message and your code.
      Which compiler are you using?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      Hanna LarssonH 1 Reply Last reply
      0
      • raven-worxR raven-worx

        @Hanna-Larsson
        this code looks actually correct.
        Can you post the exact error message and your code.
        Which compiler are you using?

        Hanna LarssonH Offline
        Hanna LarssonH Offline
        Hanna Larsson
        wrote on last edited by
        #3

        @raven-worx I found the error, in my header it looked like this:

        QList <QHBoxLayout*> listOfFieldLayouts;
        

        which was wrong. Changed it to:

        QList <QHBoxLayout*> *listOfFieldLayouts;
        

        Thanks for your time!

        Bonjour!

        raven-worxR 1 Reply Last reply
        1
        • Hanna LarssonH Hanna Larsson

          @raven-worx I found the error, in my header it looked like this:

          QList <QHBoxLayout*> listOfFieldLayouts;
          

          which was wrong. Changed it to:

          QList <QHBoxLayout*> *listOfFieldLayouts;
          

          Thanks for your time!

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @Hanna-Larsson said:

          which was wrong. Changed it to:

          which wasn't the case in the time i replied right?

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          Hanna LarssonH 1 Reply Last reply
          0
          • raven-worxR raven-worx

            @Hanna-Larsson said:

            which was wrong. Changed it to:

            which wasn't the case in the time i replied right?

            Hanna LarssonH Offline
            Hanna LarssonH Offline
            Hanna Larsson
            wrote on last edited by
            #5

            @raven-worx When you replied I hadn't changed the header-file.

            Bonjour!

            1 Reply Last reply
            0

            • Login

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