Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGraphicsLayout & QGraphicsObject

QGraphicsLayout & QGraphicsObject

Scheduled Pinned Locked Moved Unsolved General and Desktop
qgraphicsobjectqgraphicslayout
2 Posts 2 Posters 655 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Suths
    wrote on last edited by
    #1

    Hi,

    I'm trying to construct a QGraphicsObject that has behavior from QGraphicsLayout (or actually QGraphicsGridLayout), such that items can be added to it. These child items are custom QGraphicsLayoutItem (& QGraphicItem). However i think i'm getting a bit confused with this approach as i'm not sure what will paint the child objects added via add item.

    I constructed a simplified example bellow:

    class Box : public QGraphicsObject, public QGraphicsGridLayout
        {
        public:
    
            Box();
    
            QRectF boundingRect() const;
    
            void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
    
        };
    
    class Section : public QGraphicsLayoutItem, public QGraphicsItem
        {
        public:
            Section();
    
            void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
    
           virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const;
    
    
            void setGeometry(const QRectF &geom);
    
            QRectF boundingRect() const;
    
        }
    

    Effectively I want a custom QGraphicsObject that has a grid layout. Can someone help me out with how I could achieve this or even if i'm going about this all wrong.

    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #2

      Hi,

      What you want to achieve is not really clear. Do you want to obtain with your classes the same thing as a Widget with a QGridLayout and other widgets in that layout ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved