Results 1 to 4 of 4

Thread: Button Function

  1. #1
    Join Date
    Dec 2018
    Posts
    9
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Button Function

    Is there a way to pop out multiple images after pressing a button? and you can set the coordinate of the images to the location where you want each images to be?
    I'm planning to make like a card animation where if the user were to press the play button, the cards from the draw pile will give random 5 cards to the players side. For now, I'm planning to only have two players as a test. So 5 cards will be randomly place to player 1 side and the player 2 side to play.
    If possible, I don't want to use any qml images or any .ui for this program.

    I hope I'm making sense here. Thanks.
    Last edited by Kuushie118; 24th January 2019 at 23:29.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Button Function

    Your program can do anything you code it to do if you connect a slot to the button's clicked() signal. And using a button click to start a simulated deal of hands of cards is only one way you might do it. The two are related only if you chose to use a button for that purpose. Don't get locked into confusing how you accomplish a goal with the goal itself.

    As for displaying the game cards, the Qt Graphics / View framework is one way to do that. You can use QGraphicsPixmapItem instances with JPG or other images to represent the cards. To simulate dealing, you can animate the position of the cards using the Qt Animation framework.

    I would suggest that you start simple. Instead of jumping into the deep end, develop a simulation that uses simple rectangles instead of card images. Learn how to use the Graphics / View architecture to create a QGraphicsScene containing the rectangles and to place the rectangles where you want them in the scene (and scaled to fit on the QGraphicsView). When you get that working, add code to move the rectangles around using a controlled animation. When that is working, find playing card images and replace the rectangles with pixmap items and those images. When that is working, add the code that implements the rules of your card game and the user interface elements your users will need to control the game and display the scores, etc.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Button Function

    Quote Originally Posted by Kuushie118 View Post
    If possible, I don't want to use any qml images or any .ui for this program.
    These seem like rather arbitrary restrictions.

    If you are using QML/QtQuick, why not use its image type?
    If you are using QtWidgets, why manually code all UI?

    Cheers,
    _

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Button Function

    These seem like rather arbitrary restrictions.
    Sometimes all the technology available in Qt can be overwhelming.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 1
    Last Post: 5th July 2014, 12:38
  2. Replies: 3
    Last Post: 11th February 2014, 10:08
  3. How to declare a function for click button event
    By prajnaranjan.das in forum Newbie
    Replies: 8
    Last Post: 24th December 2010, 13:17
  4. Replies: 4
    Last Post: 27th November 2009, 14:00
  5. How to call a function when i clic a button?
    By trend900 in forum Newbie
    Replies: 2
    Last Post: 22nd January 2009, 17:40

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.