Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

C++ Qt framework Was wondering what else I needed to add and/or change for the main.cpp The goal of this exercise is to build a

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

C++

Qt framework

Was wondering what else I needed to add and/or change for the main.cpp

image text in transcribed

image text in transcribed

image text in transcribed

The goal of this exercise is to build a stand-alone program that will allow a user to display images of the standard 52-card deck of French-suited playing cards. The graphical user interface should support two things: The layout of all 52 cards of the deck, and three buttons that the user can use to control the GUI: the Shuffle button, the Reset button, and the Quit button. This application is meant as a start to the implementation of games that might use 52-card decks. In this initial stage, the goal is the layout of card images on a 413 grid (4 rows and 13 columns). In the initial position, each row should be a suit of cards: Diamonds in row 1, then Hearts in Row 2 , then Spades in row 3 , and finally Clubs in row 4 . The three control buttons (Shuffle, Reset, and Quit), which are not part of the grid, should sit on the interface below the cards, i.e. at the bottom of the interface. The GUI actions should function as follows: - Initial layout will organize the cards as above (Diamonds in row 1, then Hearts, Spades, and Clubs). The cards should be organized from left to right in order: Ace, 2, 3, 4, 5, 6, 7, 8, 9 , 10, Jack, Queen, King. This is the starting organization that you should show when the program is first launched (see Figure 1). - The buttons should all function independently. The user can click any of the three any time. - Shuffle button: shuffle the cards and layout the newly-shuffled cards on the interface. Every time the Shuffle button is clicked, the cards should be shuffled anew and repositioned on the layout (see Figure 2) Reset button: put the card layout back to the initial position (Diamonds in row 1, etc., with cards in ascending order from left to right). Quit button: end the application. Figure 1: Initial Card Layout One way to approach this layout problem is to use parallel vectors of QPushButton and Card objects, as demonstrated in the griddemo example from class. The icons should be read from the resource file system. Another thing to consider is the layout of the cards. A QGridLayout will work fine, but placing all cards on the layout manually may be tedious. Consider adding the cards algorithmically in the MainWindow constructor using the QWidget: : addWidget() member function. Since your cards are stored in a std::vector, you can easily use the std::shuffle and std::sort algorithms for shuffling and sorting. Using std::sort will require you to overload Figure 2: Shuffled Cards operator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions