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. QPushButton board
Qt 6.11 is out! See what's new in the release blog

QPushButton board

Scheduled Pinned Locked Moved Game Development
6 Posts 3 Posters 4.7k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello, you need to do a board where you can click a button and it tells me to coordinate the board is that button.

    I am new in Qt and i use QtCreator, not as I can make a matrix of buttons in the editor or something that not many buttons on a layout, any ideas?

    regards

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      Sorry, I absolutly do not get the question. What do you want to achieve?

      A Gameboard (like a chess board) with buttons and if you click one, get the field coordinate (like A8)?

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        yeah! ^^

        but the field coordinate its (int, int)

        I think a board is made with several buttons but maybe there is another way

        thanks for answer
        regards

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          You could use a "QSignalMapper":http://doc.qt.nokia.com/4.7/qsignalmapper.html and connect all buttons with a "QSignalMapper":http://doc.qt.nokia.com/4.7/qsignalmapper.html and map the id to coordinates.

          Or you use QPushButtons and "dynamic properties,":http://doc.qt.nokia.com/4.7/qobject.html#dynamic-properties connect all buttons to the same slot and use sender() to get the button and read the "dynamic property.":http://doc.qt.nokia.com/4.7/qobject.html#dynamic-properties

          Or you create a subclassed button which gets the x/y coordinates as propertioes and create custom signals that contain the x/y values.

          And there are even more possibilities...

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            The last option is probably the cleanest, though you could also just make the whole grid of buttons into a class that has such a clicked(int, int) signal instead, and use an internal QSignalMapper and some basic math to map a single ID to an (int, int) coordinate.

            [small]You're not trying to make a calendar out of it, are you?[/small]

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              ok thanks

              i will implement their ideas to see what I find

              not a calendar btw ^^

              really thanks

              greetings

              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