qt - Render a QQuickItem on a second window without changing its parent hierarchy -


i have render qquickitem owned particular window, another. myqquickitem owned window1 rendered on window2. switch has happen in app repeatedly due functionality.

i following achieve goal & the code works fine.

code:

myqquickitem * myquickitem = qmlengine->rootobjects()[0]->findchild<qquickitem*>("myquickitemobject"); myquickitem->setparentitem(window1->contentitem());  // required on window2  // set window1 parent again myquickitem->setparentitem(window2->contentitem()); 

problem:
above technique functionally works fine. requires me flip flop few times juggling between setting parent item window1 window2 & again.

question:
there some other way share myqquickitem between 2 windows? or possible display myqquickitem on both windows alternatively without having change parent hierarchy?

you might use grabtoimage() , display grabbed image on second window.
might not ideal, performance wise. can find questions on how on site. interesting might this.

i don't know case, might better, have 2 instances of same component displaying same data model - possible input 1 disabled.


Comments