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. Give me a head start please!
Forum Updated to NodeBB v4.3 + New Features

Give me a head start please!

Scheduled Pinned Locked Moved Solved General and Desktop
28 Posts 4 Posters 9.5k Views 2 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.
  • P Offline
    P Offline
    peteritv
    wrote on last edited by
    #5

    Suppose we start with an fixed array of cards...

    Suits: 0-3 Meaning Clubs to Spades
    Ranks: 0-12 Meaning 2 to ace

    1 Reply Last reply
    0
    • P Offline
      P Offline
      peteritv
      wrote on last edited by
      #6

      I get lost in all the tal about QAbstract* and QItem* talk

      P 1 Reply Last reply
      0
      • P peteritv

        I get lost in all the tal about QAbstract* and QItem* talk

        P Offline
        P Offline
        peteritv
        wrote on last edited by
        #7

        @peteritv said in Give me a head start please!:

        I get lost in all the tal about QAbstract* and QItem* talk

        Can Someone please advise me how to start, with in mind that every change (every card played) should be kept in a database?

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

          Hi,

          Not a direct answer but you may find the KPatience game interesting to help you get started.

          Hope it helps.

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

          P 1 Reply Last reply
          1
          • P peteritv

            @peteritv said in Give me a head start please!:

            I get lost in all the tal about QAbstract* and QItem* talk

            Can Someone please advise me how to start, with in mind that every change (every card played) should be kept in a database?

            P Offline
            P Offline
            peteritv
            wrote on last edited by
            #9

            @peteritv said in Give me a head start please!:

            @peteritv said in Give me a head start please!:

            I get lost in all the tal about QAbstract* and QItem* talk

            Can Someone please advise me how to start, with in mind that every change (every card played) should be kept in a database?

            I started out with:

            Class Card{
            <some_enum> suit;
            <some_enum> rank;
            }

            Everything should be acessible to C=++:

            So is it better to write this in QML?

            1 Reply Last reply
            0
            • SGaistS SGaist

              Hi,

              Not a direct answer but you may find the KPatience game interesting to help you get started.

              Hope it helps.

              P Offline
              P Offline
              peteritv
              wrote on last edited by
              #10

              @SGaist Hi SGaist, KPatience shows promise, but does not explain anything, right? :(

              I need to find a way to tell the system to when to print a Card as PDF (for example, using the HTML view), or to put it on screen using the picture view.

              Sorry I am such a beginner...

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

                Something like QPdfWriter ?

                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
                • P peteritv

                  @SGaist Hi SGaist, KPatience shows promise, but does not explain anything, right? :(

                  I need to find a way to tell the system to when to print a Card as PDF (for example, using the HTML view), or to put it on screen using the picture view.

                  Sorry I am such a beginner...

                  P Offline
                  P Offline
                  peteritv
                  wrote on last edited by
                  #12

                  @peteritv
                  For example:

                  In a PDF I want to display how a game was played, using something like:

                  "Trick 1: ♠5 ♣4 ♥6 ♠8""
                  Trick was won by ♠8

                  P 1 Reply Last reply
                  0
                  • P peteritv

                    @peteritv
                    For example:

                    In a PDF I want to display how a game was played, using something like:

                    "Trick 1: ♠5 ♣4 ♥6 ♠8""
                    Trick was won by ♠8

                    P Offline
                    P Offline
                    peteritv
                    wrote on last edited by
                    #13

                    @peteritv said in Give me a head start please!:

                    @peteritv
                    For example:

                    In a PDF I want to display how a game was played, using something like:

                    "Trick 1: ♠5 ♣4 ♥6 ♠8""
                    Trick was won by ♠8

                    While in the mean time, with the same setup, on screen the correct images (pixmap 100x150 or so) of the cards are shown.

                    P 1 Reply Last reply
                    0
                    • P peteritv

                      @peteritv said in Give me a head start please!:

                      @peteritv
                      For example:

                      In a PDF I want to display how a game was played, using something like:

                      "Trick 1: ♠5 ♣4 ♥6 ♠8""
                      Trick was won by ♠8

                      While in the mean time, with the same setup, on screen the correct images (pixmap 100x150 or so) of the cards are shown.

                      P Offline
                      P Offline
                      peteritv
                      wrote on last edited by
                      #14

                      @peteritv
                      I will have something like a "Trick" Class, that shows what 4 cards (4 players) are being played onScreen...
                      It will show images of the 4 cards involved into specific "Seats".

                      So suppose Players "North", "East", "South" and "West",
                      When a Card is played, onscreen I want to see the image (CA.png for club ace), but in PDF I want to see <♣A>

                      It will show images of the cards being played (the pixmaps), and when I want to document, I want to show the HTML view

                      P 1 Reply Last reply
                      0
                      • P peteritv

                        @peteritv
                        I will have something like a "Trick" Class, that shows what 4 cards (4 players) are being played onScreen...
                        It will show images of the 4 cards involved into specific "Seats".

                        So suppose Players "North", "East", "South" and "West",
                        When a Card is played, onscreen I want to see the image (CA.png for club ace), but in PDF I want to see <♣A>

                        It will show images of the cards being played (the pixmaps), and when I want to document, I want to show the HTML view

                        P Offline
                        P Offline
                        peteritv
                        wrote on last edited by
                        #15

                        @peteritv Let me alloborate further: My object "Card" may have many representations... On screen it will be a pixmap (Club Ace will be represented by CA.png), but for a document it will be represented by the HTML value "♣A" or maybe even "CA"

                        Now I not really that newby that doesn't know the difference, I just don't know how things like that work in Qt.
                        And Preferrably is such a way that QML knows about it too.

                        P 1 Reply Last reply
                        0
                        • P peteritv

                          @peteritv Let me alloborate further: My object "Card" may have many representations... On screen it will be a pixmap (Club Ace will be represented by CA.png), but for a document it will be represented by the HTML value "♣A" or maybe even "CA"

                          Now I not really that newby that doesn't know the difference, I just don't know how things like that work in Qt.
                          And Preferrably is such a way that QML knows about it too.

                          P Offline
                          P Offline
                          peteritv
                          wrote on last edited by
                          #16

                          @peteritv said in Give me a head start please!:

                          @peteritv Let me alloborate further: My object "Card" may have many representations... On screen it will be a pixmap (Club Ace will be represented by CA.png), but for a document it will be represented by the HTML value "♣A" or maybe even "CA"

                          Now I not really that newby that doesn't know the difference, I just don't know how things like that work in Qt.
                          And Preferrably is such a way that QML knows about it too.

                          So suppose I have a Class "Card" with attributes "int Suit" and "int Rank".
                          Simple class right?

                          How do I expose views that show the onScreen , onPDF, etc variants?

                          P 1 Reply Last reply
                          0
                          • P peteritv

                            @peteritv said in Give me a head start please!:

                            @peteritv Let me alloborate further: My object "Card" may have many representations... On screen it will be a pixmap (Club Ace will be represented by CA.png), but for a document it will be represented by the HTML value "♣A" or maybe even "CA"

                            Now I not really that newby that doesn't know the difference, I just don't know how things like that work in Qt.
                            And Preferrably is such a way that QML knows about it too.

                            So suppose I have a Class "Card" with attributes "int Suit" and "int Rank".
                            Simple class right?

                            How do I expose views that show the onScreen , onPDF, etc variants?

                            P Offline
                            P Offline
                            peteritv
                            wrote on last edited by
                            #17

                            @peteritv said in Give me a head start please!:

                            @peteritv said in Give me a head start please!:

                            @peteritv Let me alloborate further: My object "Card" may have many representations... On screen it will be a pixmap (Club Ace will be represented by CA.png), but for a document it will be represented by the HTML value "♣A" or maybe even "CA"

                            Now I not really that newby that doesn't know the difference, I just don't know how things like that work in Qt.
                            And Preferrably is such a way that QML knows about it too.

                            So suppose I have a Class "Card" with attributes "int Suit" and "int Rank".
                            Simple class right?

                            How do I expose views that show the onScreen , onPDF, etc variants?

                            So I have some kind of list of "Cards"
                            Preferrably some kind of sorting on it...

                            And a player plays a card...

                            P 1 Reply Last reply
                            0
                            • P peteritv

                              @peteritv said in Give me a head start please!:

                              @peteritv said in Give me a head start please!:

                              @peteritv Let me alloborate further: My object "Card" may have many representations... On screen it will be a pixmap (Club Ace will be represented by CA.png), but for a document it will be represented by the HTML value "♣A" or maybe even "CA"

                              Now I not really that newby that doesn't know the difference, I just don't know how things like that work in Qt.
                              And Preferrably is such a way that QML knows about it too.

                              So suppose I have a Class "Card" with attributes "int Suit" and "int Rank".
                              Simple class right?

                              How do I expose views that show the onScreen , onPDF, etc variants?

                              So I have some kind of list of "Cards"
                              Preferrably some kind of sorting on it...

                              And a player plays a card...

                              P Offline
                              P Offline
                              peteritv
                              wrote on last edited by
                              #18

                              @peteritv said in Give me a head start please!:

                              @peteritv said in Give me a head start please!:

                              @peteritv said in Give me a head start please!:

                              @peteritv Let me alloborate further: My object "Card" may have many representations... On screen it will be a pixmap (Club Ace will be represented by CA.png), but for a document it will be represented by the HTML value "♣A" or maybe even "CA"

                              Now I not really that newby that doesn't know the difference, I just don't know how things like that work in Qt.
                              And Preferrably is such a way that QML knows about it too.

                              So suppose I have a Class "Card" with attributes "int Suit" and "int Rank".
                              Simple class right?

                              How do I expose views that show the onScreen , onPDF, etc variants?

                              So I have some kind of list of "Cards"
                              Preferrably some kind of sorting on it...

                              And a player plays a card...

                              For the game of "Bridge"
                              Let's say we have 4 players: "North", "East", "South" and "West"

                              How do I define that so that QML knows about it?

                              P 1 Reply Last reply
                              0
                              • P peteritv

                                @peteritv said in Give me a head start please!:

                                @peteritv said in Give me a head start please!:

                                @peteritv said in Give me a head start please!:

                                @peteritv Let me alloborate further: My object "Card" may have many representations... On screen it will be a pixmap (Club Ace will be represented by CA.png), but for a document it will be represented by the HTML value "♣A" or maybe even "CA"

                                Now I not really that newby that doesn't know the difference, I just don't know how things like that work in Qt.
                                And Preferrably is such a way that QML knows about it too.

                                So suppose I have a Class "Card" with attributes "int Suit" and "int Rank".
                                Simple class right?

                                How do I expose views that show the onScreen , onPDF, etc variants?

                                So I have some kind of list of "Cards"
                                Preferrably some kind of sorting on it...

                                And a player plays a card...

                                For the game of "Bridge"
                                Let's say we have 4 players: "North", "East", "South" and "West"

                                How do I define that so that QML knows about it?

                                P Offline
                                P Offline
                                peteritv
                                wrote on last edited by
                                #19

                                @peteritv said in Give me a head start please!:

                                @peteritv said in Give me a head start please!:

                                @peteritv said in Give me a head start please!:

                                @peteritv said in Give me a head start please!:

                                @peteritv Let me alloborate further: My object "Card" may have many representations... On screen it will be a pixmap (Club Ace will be represented by CA.png), but for a document it will be represented by the HTML value "♣A" or maybe even "CA"

                                Now I not really that newby that doesn't know the difference, I just don't know how things like that work in Qt.
                                And Preferrably is such a way that QML knows about it too.

                                So suppose I have a Class "Card" with attributes "int Suit" and "int Rank".
                                Simple class right?

                                How do I expose views that show the onScreen , onPDF, etc variants?

                                So I have some kind of list of "Cards"
                                Preferrably some kind of sorting on it...

                                And a player plays a card...

                                For the game of "Bridge"
                                Let's say we have 4 players: "North", "East", "South" and "West"

                                How do I define that so that QML knows about it?

                                But to start with:
                                How do I know what "Game" to start with?

                                A "CardGame" may be a local thing, may be referenced by a Single person or an onLine thing....

                                Let's focus on "CardGame" being a local thing.

                                And let's say that "Bridge" is our focus of cardgames.

                                "Bridge" has rules:
                                For instance:
                                Ace is highest
                                2 is lowest
                                Trump is highest

                                I think that summons up the ruler of a "Bridge" trick,
                                right?

                                So: If not trumped, Ace is highest
                                But if Trumped:

                                1 Reply Last reply
                                0
                                • thamT Offline
                                  thamT Offline
                                  tham
                                  wrote on last edited by
                                  #20

                                  Maybe v-play could give you some help, it provide a decent card game example.

                                  P 1 Reply Last reply
                                  0
                                  • thamT tham

                                    Maybe v-play could give you some help, it provide a decent card game example.

                                    P Offline
                                    P Offline
                                    peteritv
                                    wrote on last edited by
                                    #21

                                    @tham
                                    V_play seems nice, but does it support card games?

                                    And it is NOT free?

                                    thamT 1 Reply Last reply
                                    0
                                    • P peteritv

                                      Please bear with me!
                                      I am super newby to Qt, QML and C++ (and OO in general)

                                      I want to develop a general card game suit of classes, for instance for the (derived) games of bridge, "Belote" or poker.

                                      Base class (Card) will be a card, with attributes suit (Clubs - Spades) and rank (2 - Ace, I don't think about jokers right now, but suggestions are welcome!).

                                      For some games, ranks may be different, for instance, the Ace may rank as lowest (as in Ace-2-3), highest (as in Q-K-Ace), or even both.
                                      How do I deal with that, keeping things as general as possible (Ace can have only 1 id, but many different meanings)?

                                      Trump J(ack) may be the absolute highest card, followed by trump 9, etc... (see https://en.wikipedia.org/wiki/Belote)
                                      Many card games, all different rules...

                                      I want to make a class CardDeck that defines the range of Card to be used, so for Bridge it will be 52 cards, suits Club to Spade, range 2 to Ace(highest)
                                      For "Belote" it will be suits Club to Spade, range 7 to Ace(highest),
                                      Other games may have suits Club to Spades with range Ace(lowest) to Ace(highest)...

                                      The thing is:

                                      • Cards can have different views (for instance: QString as in "C4", HTML as in "<♣4>", or an image...)

                                      A card may be shown as:

                                      • Text literal ("C4")
                                      • HTML (♣4)

                                      You get my drift...

                                      Now how do I start to set this up, with remark that all should be accesible by both C++ (which will probably handle the data and model) and QML (which will probaly handle views)?

                                      I have read all the stories, but get lost ...

                                      P Offline
                                      P Offline
                                      peteritv
                                      wrote on last edited by
                                      #22

                                      @peteritv said in Give me a head start please!:

                                      Please bear with me!
                                      I am super newby to Qt, QML and C++ (and OO in general)

                                      I want to develop a general card game suit of classes, for instance for the (derived) games of bridge, "Belote" or poker.

                                      Base class (Card) will be a card, with attributes suit (Clubs - Spades) and rank (2 - Ace, I don't think about jokers right now, but suggestions are welcome!).

                                      For some games, ranks may be different, for instance, the Ace may rank as lowest (as in Ace-2-3), highest (as in Q-K-Ace), or even both.
                                      How do I deal with that, keeping things as general as possible (Ace can have only 1 id, but many different meanings)?

                                      Trump J(ack) may be the absolute highest card, followed by trump 9, etc... (see https://en.wikipedia.org/wiki/Belote)
                                      Many card games, all different rules...

                                      I want to make a class CardDeck that defines the range of Card to be used, so for Bridge it will be 52 cards, suits Club to Spade, range 2 to Ace(highest)
                                      For "Belote" it will be suits Club to Spade, range 7 to Ace(highest),
                                      Other games may have suits Club to Spades with range Ace(lowest) to Ace(highest)...

                                      The thing is:

                                      • Cards can have different views (for instance: QString as in "C4", HTML as in "<♣4>", or an image...)

                                      A card may be shown as:

                                      • Text literal ("C4")
                                      • HTML (♣4)
                                      • an image

                                      You get my drift...

                                      Now how do I start to set this up, with remark that all should be accesible by both C++ (which will probably handle the data and model) and QML (which will probaly handle views)?

                                      I have read all the stories, but get lost ...

                                      P 1 Reply Last reply
                                      0
                                      • P peteritv

                                        @peteritv said in Give me a head start please!:

                                        Please bear with me!
                                        I am super newby to Qt, QML and C++ (and OO in general)

                                        I want to develop a general card game suit of classes, for instance for the (derived) games of bridge, "Belote" or poker.

                                        Base class (Card) will be a card, with attributes suit (Clubs - Spades) and rank (2 - Ace, I don't think about jokers right now, but suggestions are welcome!).

                                        For some games, ranks may be different, for instance, the Ace may rank as lowest (as in Ace-2-3), highest (as in Q-K-Ace), or even both.
                                        How do I deal with that, keeping things as general as possible (Ace can have only 1 id, but many different meanings)?

                                        Trump J(ack) may be the absolute highest card, followed by trump 9, etc... (see https://en.wikipedia.org/wiki/Belote)
                                        Many card games, all different rules...

                                        I want to make a class CardDeck that defines the range of Card to be used, so for Bridge it will be 52 cards, suits Club to Spade, range 2 to Ace(highest)
                                        For "Belote" it will be suits Club to Spade, range 7 to Ace(highest),
                                        Other games may have suits Club to Spades with range Ace(lowest) to Ace(highest)...

                                        The thing is:

                                        • Cards can have different views (for instance: QString as in "C4", HTML as in "<♣4>", or an image...)

                                        A card may be shown as:

                                        • Text literal ("C4")
                                        • HTML (♣4)
                                        • an image

                                        You get my drift...

                                        Now how do I start to set this up, with remark that all should be accesible by both C++ (which will probably handle the data and model) and QML (which will probaly handle views)?

                                        I have read all the stories, but get lost ...

                                        P Offline
                                        P Offline
                                        peteritv
                                        wrote on last edited by
                                        #23

                                        @peteritv
                                        A simple thing as a "Card" (with just a suit and rank) does not know anything about how it is supposed to be viewed, right?

                                        The "Card" itself is just data.

                                        This data needs to go into some model, that processes the data.
                                        Since the "Card" itself will never change, I am thinking about a "QItemStandardModel"
                                        Just to hold the "Card" instances and being able to sort/add/delete a "Card"...

                                        So, the model contains "Cards" (with multiple instances of "Card")
                                        And there will be multiple views to show that.
                                        Basiccaly a "Deck of cards" will be a "TableView" I guess, since there is 2 dimensional data namely suit and rank.

                                        When a trick is played (game of Bridge for example) there will be 4 "Card" instances that will leave the "Complete" model and enter some new model of "Played".
                                        Right?

                                        When you think about "Card"s
                                        It is hard to NOT think about views, but fact is that sometimes you want just "♣4" and sometimes you want the full PNG image...

                                        The goal of this topic is (and was from the beginning) how to setup things in Qt (and/or QML) so that both C++ and QML know that a "Card" has been played, and can adjust the new actions to take.

                                        P 1 Reply Last reply
                                        0
                                        • P peteritv

                                          @peteritv
                                          A simple thing as a "Card" (with just a suit and rank) does not know anything about how it is supposed to be viewed, right?

                                          The "Card" itself is just data.

                                          This data needs to go into some model, that processes the data.
                                          Since the "Card" itself will never change, I am thinking about a "QItemStandardModel"
                                          Just to hold the "Card" instances and being able to sort/add/delete a "Card"...

                                          So, the model contains "Cards" (with multiple instances of "Card")
                                          And there will be multiple views to show that.
                                          Basiccaly a "Deck of cards" will be a "TableView" I guess, since there is 2 dimensional data namely suit and rank.

                                          When a trick is played (game of Bridge for example) there will be 4 "Card" instances that will leave the "Complete" model and enter some new model of "Played".
                                          Right?

                                          When you think about "Card"s
                                          It is hard to NOT think about views, but fact is that sometimes you want just "♣4" and sometimes you want the full PNG image...

                                          The goal of this topic is (and was from the beginning) how to setup things in Qt (and/or QML) so that both C++ and QML know that a "Card" has been played, and can adjust the new actions to take.

                                          P Offline
                                          P Offline
                                          peteritv
                                          wrote on last edited by
                                          #24

                                          @peteritv said in Give me a head start please!:

                                          @peteritv
                                          A simple thing as a "Card" (with just a suit and rank) does not know anything about how it is supposed to be viewed, right?

                                          The "Card" itself is just data.

                                          This data needs to go into some model, that processes the data.
                                          Since the "Card" itself will never change, I am thinking about a "QItemStandardModel"
                                          Just to hold the "Card" instances and being able to sort/add/delete a "Card"...

                                          So, the model contains "Cards" (with multiple instances of "Card")
                                          And there will be multiple views to show that.
                                          Basiccaly a "Deck of cards" will be a "TableView" I guess, since there is 2 dimensional data namely suit and rank.

                                          When a trick is played (game of Bridge for example) there will be 4 "Card" instances that will leave the "Complete" model and enter some new model of "Played".
                                          Right?

                                          When you think about "Card"s
                                          It is hard to NOT think about views, but fact is that sometimes you want just "♣4" and sometimes you want the full PNG image...

                                          The goal of this topic is (and was from the beginning) how to setup things in Qt (and/or QML) so that both C++ and QML know that a "Card" has been played, and can adjust the new actions to take.

                                          Referencing me to some (paid) extension does not help me to understand how to solve this problem in Qt.

                                          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