Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4242220
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:24:47+00:00 2026-05-21T03:24:47+00:00

I should start by saying I’ve tried to look at this problem from all

  • 0

I should start by saying I’ve tried to look at this problem from all POVs. I’ve also asked on freenode and I was suggested some things, yet in the end it turned out those suggestions could not possibly work.

It looked to me as though those making suggestions don’t really know how the class hierarchy and the concepts hierarchy looks like.

That being said, I haven’t used Qt for years, so please bear with me.

What I want to make is a graphics item (QGraphicsWidget,…Item, whatever, I don’t know what class it should inherit from) that can sit on the scenery QGraphicsScene.

Imagine you wanted to create a reusable component for grid-based games like battleship.

New objects (like a battleship) within this widget could be represented as bit matrices and created/inserted on the fly.

The building blocks themselves (filled QGraphicsRectItem or “empty” ones) inside it should be managed by a layout class. As a default could serve QGraphicsGridLayout, but it should allow plugging in a custom layout. This would allow new 2D layouts, like isometric.

Having a layout inside the widget would also simplify game development on top of this widget, as you’ll have methods itemAt() and layers to organize the objects on the “grid”.

And remember, the widget itself can sit inside the scenery.

So which concepts (grid widget, grid block, grid layout) should inherit from which qt4 (4.7.2) classes?

Note: already exiting classes/frameworks/whatever are also OK, but keep in mind I don’t want to have to distribute libraries thicker than 3-4 Mb for windows users.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T03:24:48+00:00Added an answer on May 21, 2026 at 3:24 am

    Based on your description, I would recommend to implement the three basic concepts as:

    1) “grid” widget inherits from QGraphicsWidget as it supports adding layouts. If you go along with QGraphicsItem, you will need to re implement the layout mechanism which is really painful. The grid creates “grid” block depending on the “grid” shape provided by the “grid” layout.

    2) “grid” layout inherits from QGraphicsLayout. You should be able to almost directly use the QGraphicsGridLayout to make simple square grid games. You will have to create new subclasses to handle other kind of grid shapes. One distinct feature you should have in this class is the definition of the shape of a grid block (square, hexagon, diamond). This definition given as a QPolygon can be used to create the correctly shaped grid block.

    3) “grid” block inherits from QGraphicsPolygonItem and QGraphicsLayoutItem. This is the more general approach to defined a grid item as a polygon. You could either have rectangle shape, diamond shape, hexagonal shape, etc.. If you want you grid object to be disk arranged in a square grid fashion (see Sane game for instance), you can create a special “grid” block item that contains (as a child) a QGraphicsEllipseItem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, I should start this off by saying I'm not sure this is necessarily
I should start by saying that I am using ASP.NET using C# in a
Let me start by saying I'm a huge fan of the elegance of this
35 lines, 55 lines, 100 lines, 300 lines? When you should start to break
Should I start with Django or JavaScript?
Should I start a Python program with: if__name__ == '__main__': some code... And if
Where should I start learning about version control systems? I've used SVN, Team Foundation,
Which family should I start to learn? (Never did any programming on microcontroller)
I'm thinking about learning COBOL. Where should I start?
There's a lot to C# & ASP.net. Where should I start? What should I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.