Greetings!
I just purchased "Foundations of Qt Development" (Johan Thelin, 2007), and I read until about chapter 4. I'm trying to practice some of this, so I dove in and I'm creating a simple whack-a-mole type game. So far, it's playable (and configurable if you don't mind changing the setDefaults() function), but the layout just sucks.
I have two problems. The scorebox on the side is a QGroupBox with a QGridLayout in it, containing for QLabels that explain your score. The labels expand nicely to fill the grid layout, but the grid layout does not expand to fill the groupbox. I have tried every conceivable size policy from the designer's property editor, and nothing seems to work. Does anyone know how to fix this?
Second, because I don't know until runtime how many rows and columns there will be in the grid of moles that you click on, I created the function createMoles(), which fills a QGridLayout with moles. A mole is a button-like widget which is 32x32 pixels in size. A grid of 8x8 of these fits nicely in the main window that I have already created with the designer, but if I increase the size of the grid very much, it just goes off the edge of the main window, and you have to manually resize the main window to see them all. Googling has revealed nothing about this problem, and when I tried changing the central widget class in my .ui file with a text editor, everything went to pot. Does anyone know a way to get the main window to automatically expand so that you can see all widgets?
I hope these aren't too complicated, but I guess it's all part of the learning process.
I uploaded a tarball of my current source code and ui file to http://www.theanythingbox.com/whack.tar.gz. The forum's attachment mechanism didn't let me upload the file as an attachment, sorry.
Thanks for any help you can provide!
- Jakykong
Bookmarks