0
votes

I want to create a Qt application with a QTabWidget, where each tab contains a QGraphicsView and a QGraphicsScene to draw a polygon on a Cartesian plane. example: first tab for a triangle, second for square, etc...

So, I create my qt application and then: - inside my class derived from QDialog, I create a QVBoxLayout, I've added my widget to this, and I've inserted it into my QTabWidget, created with QDesigner: I repeat this operation for each tab of QTabWidget. I want to know if it's a bad practice to add a QGraphicsScene into a tab in this way or to redefine all the classes from qwidget, view, and scene.

  • out of the QTabwidget, i have some QPushButtons that do some operations on the QGraphicsScene's polygons: when i click on a polygon, i want to do some operations through the QpushButton, like sum the angles (only on the polygon that I've clicked). How do I communicate to the QPushButton (out of the QTabWidget) that I've clicked a polygon and which one I've clicked(inside QTabWidget)?
  • the private data field of my_scene contains a QList of triangles (derived from QGraphicsPolygonItem)

https://i.stack.imgur.com/Pu329.jpg

1
So, what is your exact question? Something is not working? If you need a code review on your design, you may post a code (not a picture) in codereview.stackexchange.com - Dmitry Sazonov

1 Answers

0
votes

I want to know if it's a bad practice

Generally speaking no, it isn't.

If you are ok with the functionality of some class you should use this class. If you need to extend it in any way you should subclass from this class and add everything you need.

It's true not only for Qt classes but for any other classes written by you or somebody else. It's one of the basic principles of inheritance.