title: Custom QML QQuickPainted Item Member anchors not set to parent in qml
body: <p>I am having a problem getting a member of a custom QQuickItem I created to anchor to its parent. I know that it is loading and the constructor is running because of some debug statements I placed, however for some reason anchoring to parent is not working on the sub-object.</p>
  
  <p>Note: lots of shortening of code happened here. I hope everything is relevant without being overwhelming</p>
  
  <p>qml Snippet</p>
  
  <pre><code>    PDFDocument
      {
          id: pdfDocument
          anchors.fill: parent
  
          visible: false
          pageView
          {
              dpi: 200
  
               //this is not working and paint is not being called
               //QML PDFPageView: Cannot anchor to an item that isn't a parent or sibling.
              anchors.fill: parent        
          }
      }
  </code></pre>
  
  <p>c++ code snippets</p>
  
  <pre><code>// PDFPageView.h
  namespace TechnicalPublications
  {
  
  class PDFPageView : public QQuickPaintedItem
  {
  public:
      Q_OBJECT
  
      Q_PROPERTY( int dpi MEMBER m_dpi NOTIFY dpiChanged )
  
  Q_SIGNALS:
      void dpiChanged();
  public:
      PDFPageView( QQuickItem* parent = nullptr );
      ~PDFPageView();
  
      void setPage( Poppler::Page* page_p );
  
      void paint( QPainter* painter_p );
  
  private:
      Poppler::Page* m_page_p;
  };
  
  }
  
  //PDFPage.cpp
  namespace TechnicalPublications
  {
  
  PDFPageView::PDFPageView( QQuickItem* parent )
      : QQuickPaintedItem( parent )
  {
      LOG_DEBUG( __FILE__, __LINE__ ) &lt;&lt; "Page parent" &lt;&lt; parent;
      LOG_DEBUG( __FILE__, __LINE__ ) &lt;&lt; "constructing PageView" &lt;&lt; this;
  }
  
  void PDFPageView::setPage( Poppler::Page* page_p )
  {
      m_page_p = page_p;
      update();
  }
  
  void PDFPageView::paint( QPainter* painter_p )
  {
      LOG_DEBUG( __FILE__, __LINE__ ) &lt;&lt; "painting pdf page";
      //deleted sections for spacing, point is paint is not called because size is 0
  }
  
  }
  
  //PDFDocument.h
  class PDFDocument : public QQuickItem
  {
  public:
      Q_OBJECT
  
      Q_PROPERTY( TechnicalPublications::PDFPageView* pageView READ getPageView )
  
      PDFDocument( QQuickItem* parent = nullptr );
      ~PDFDocument();
  
      PDFPageView* getPageView() { return &amp;m_pageView; }
  private:
      PDFPageView m_pageView;
  };
  
  }
  #endif // PDFDOCUMENT_H
  
  //PDFDocument.cpp
  namespace TechnicalPublications
  {
  
  PDFDocument::PDFDocument( QQuickItem* parent /*= nullptr*/ )
      : QQuickItem( parent ),
        m_pageView( this )
  {
      LOG_DEBUG( __FILE__, __LINE__ ) &lt;&lt; "Document parent " &lt;&lt; parent;
      LOG_DEBUG( __FILE__, __LINE__ ) &lt;&lt; "constructing Document " &lt;&lt; this;
  }
  
  PDFDocument::~PDFDocument()
  {
  }
  
  }
  </code></pre>
  
  <p>I would even be happy to set the anchors to always take the parent in the c++ is possible, but I know visual settings like that are supposed to be handled in QML specifically. Any thoughts on why this is being a problem?</p>