Results 1 to 7 of 7

Thread: Shuffling deck cards Animation with images(gif)

Threaded View

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

    Default Re: Shuffling deck cards Animation with images(gif)

    Will I use console or widget application in creating a new project?
    Widget application is what you usually want if you have a Qt GUI. If you want menus, toolbars, etc., then you would choose a main window-based application instead of a dialog-based one. If you use a main window, set the QGraphicsView as the "centralWidget" of the main window. You will also want to override the resizeEvent() of the main window and call QGraphicsView::fitInView() using a QRect based on the resize event's QSize to create the correct scaling so the scene is scaled to fit the window.

    card images from a resource file?
    That's the best way to do it. All the images are compiled into the program instead of living as separate image files that have to be loaded at runtime. It would probably be a good idea to name your resource images so you can generate the name in a loop (e.g. "card01.png" instead of "aceofspades.png"). Otherwise you'll have to write 52 lines to load the images one-by-one instead of three lines to load them in a loop. You can make an enum that allows you to know the card (eAceOfSpaces = 01, eTwoOfSpades = 02, etc.) and match it to the correct index (card01, card02, ... ), the correct QGraphicsPixmapItem, the correct logical card, and so forth.
    Last edited by d_stranz; 28th December 2018 at 06:06.
    <=== 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.

  2. The following user says thank you to d_stranz for this useful post:

    Kuushie118 (30th December 2018)

Similar Threads

  1. Replies: 1
    Last Post: 3rd May 2017, 11:54
  2. Replies: 2
    Last Post: 8th January 2015, 19:15
  3. Replies: 1
    Last Post: 27th July 2012, 16:33
  4. newbie on deck
    By Hirsutum in forum General Programming
    Replies: 2
    Last Post: 27th May 2010, 07:06

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.