Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. [solved] deal cards and add to the scene
Forum Updated to NodeBB v4.3 + New Features

[solved] deal cards and add to the scene

Scheduled Pinned Locked Moved Game Development
29 Posts 2 Posters 10.3k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #14

    What's the exact error you are getting ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Marcius
      wrote on last edited by
      #15

      error C2248: 'QGraphicsPixmapItem::QGraphicsPixmapItem' : cannot access private member declared in class 'QGraphicsPixmapItem'

      error C2248: 'QGraphicsPixmapItem::operator =' : cannot access private member declared in class 'QGraphicsPixmapItem'

      And that's compiler's output:

      1> c:\qt\5.2.1\msvc2012\include\qtwidgets\qgraphicsitem.h(866) : see declaration of 'QGraphicsPixmapItem::QGraphicsPixmapItem'
      1> c:\qt\5.2.1\msvc2012\include\qtwidgets\qgraphicsitem.h(822) : see declaration of 'QGraphicsPixmapItem'
      1> This diagnostic occurred in the compiler generated function 'Card::Card(const Card &)'

      and

      'Card &Card::operator =(const Card &)'

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Marcius
        wrote on last edited by
        #16

        I can't believe I did it (given my almost non-existent experience), but I finally got rid of the errors by providing my own class copy and assignment operator constructors. Please keep tuned though, will see where it leads me to.. :)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #17

          What you are doing is risky, you've got the error because the base class (QGraphicsPixmapItem ) explicitly forbids the copy.

          If you look at QGraphicsScene you see that you addItem takes a pointer to an item

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Marcius
            wrote on last edited by
            #18

            I see what you're saying. I actually may be having problems because of that at the moment (not sure yet though). How would you go about this issue then? Quite frankly, I still don't know which which part of my program causes the error.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #19

              Just allocate your Cards on the heap and not on the stack

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Marcius
                wrote on last edited by
                #20

                I tried that, although I still can't remove copy and assignment operator constructors without getting the same error..

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #21

                  Because somewhere in your code you are doing a copy. Are you using a QList<Card> or something similar ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Marcius
                    wrote on last edited by
                    #22

                    I saw your reply in my other post and I indeed did do copies by using vector. I'm changing my code around now.

                    Check this line @ vector<Card*> * player = new vector<Card*>; @ Is it correct? And if so, how do I iterate through player? I'm getting a little confused with all these pointers.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #23

                      Just use vector<Card *> player, there's no need of a pointer for the vector

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        Marcius
                        wrote on last edited by
                        #24

                        @
                        for (vector<Card*>::iterator iter = player.begin();
                        iter != player.end(); ++iter)
                        {
                        qDebug() << iter->GetSuit()
                        }
                        @

                        How do I call GetSuit() function? This is obviously incorrect

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #25

                          With

                          @(*iter)->GetSuit();@

                          You should be good

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            Marcius
                            wrote on last edited by
                            #26

                            Tried it before I asked :) But I get an error: "expression must have pointer-to-class type"

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #27

                              Sorry, there was a mistake in my code example

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                Marcius
                                wrote on last edited by
                                #28

                                Ah, simple as that. Works like a charm :)

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #29

                                  Yes, sometimes it's a simple thing :) But can be hard to track down :-D

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  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