To get "regular" items movable, you have to set <span class="Apple-style-span" style="font-family:'Times New Roman';font-size:medium">ItemIsMovable </span>flag on the item - e.g. item->setFlag(QGraphicsItem::ItemIsMovable, true) - not sure if you have to do the same thing with a widget item or not....<br>

<br><div class="gmail_quote">On Wed, Aug 15, 2012 at 11:43 AM, Nehemiah Dacres <span dir="ltr"><<a href="mailto:vivacarlie@gmail.com" target="_blank">vivacarlie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<span style="color:rgb(34,34,34);font-size:12.727272033691406px;font-family:arial,sans-serif">is there a way to create a floating table widget that you can move around on a QGrahicsView. Just using addWidget gets you an immobile table in the view. I tried embedding it in a QFocusFrame but when i add it, I dont' know how to make it render. Here's the code </span><div style="color:rgb(34,34,34);font-size:12.727272033691406px;font-family:arial,sans-serif">



<br></div><div style="color:rgb(34,34,34);font-size:12.727272033691406px;font-family:arial,sans-serif"><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">void</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">MainWindow</span>::on_actionAddTable_triggered()</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">{</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,128,0)">//add table</span></pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">QTableWidget</span>*<span style="color:rgb(192,192,192)"> </span>newTable<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">new</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QTableWidget</span>(<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">3</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">3</span>);</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,128,0)">//newTable->setHorizontalHeaderLabels(QStringList()<<"1"<<"2"<<"3");</span></pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,128,0)">//newTable->setVerticalHeaderLabels(QStringList()<<"A"<<"B"<<"C");</span></pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,128,0)">//qDebug() <<" table labled";</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">

<span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,128,0)">// row mod(26) = letter;</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">QWidget</span><span style="color:rgb(192,192,192)"> </span>*<span style="color:rgb(192,192,192)"> </span>thisPage<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">pageStack</span>->currentWidget();</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">QGraphicsView</span><span style="color:rgb(192,192,192)"> </span>*<span style="color:rgb(192,192,192)"> </span>thePage<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">dynamic_cast</span><<span style="color:rgb(128,0,128)">QGraphicsView</span>*>(thisPage);</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">QGraphicsScene</span><span style="color:rgb(192,192,192)"> </span>*<span style="color:rgb(192,192,192)"> </span>thisScene<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>thePage->scene();</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span>qDebug()<span style="color:rgb(192,192,192)"> </span><<<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"scene aquired "</span>;</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span>thisScene->addWidget(newTable);</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">

<span style="color:rgb(192,192,192)">    </span>qDebug()<span style="color:rgb(192,192,192)"> </span><<<span style="color:rgb(0,128,0)">"table added"</span>;</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">

<span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">QFocusFrame</span><span style="color:rgb(192,192,192)"> </span>*<span style="color:rgb(192,192,192)"> </span>tableProxy<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">new</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QFocusFrame</span>();</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span>qDebug()<span style="color:rgb(192,192,192)"> </span><<<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"new frame"</span>;</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span>tableProxy->setWidget(newTable);</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">

<span style="color:rgb(192,192,192)">    </span>qDebug()<<<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"set widgit"</span>;</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">

<span style="color:rgb(192,192,192)">    </span>tableProxy-><span style="font-style:italic">setVisible</span>(<span style="color:rgb(128,128,0)">true</span>);</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">

<span style="color:rgb(192,192,192)">    </span>qDebug()<<<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"set widgit"</span>;</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">

}</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">and it crashes after qDebug outputs set widgit, mean time so does this </pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">void</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">MainWindow</span>::on_actionAddTable_triggered()</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">{</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,128,0)">//add table</span></pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">QTableWidget</span>*<span style="color:rgb(192,192,192)"> </span>newTable<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">new</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QTableWidget</span>(<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">3</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">3</span>);</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,128,0)">//newTable->setHorizontalHeaderLabels(QStringList()<<"1"<<"2"<<"3");</span></pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,128,0)">//newTable->setVerticalHeaderLabels(QStringList()<<"A"<<"B"<<"C");</span></pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,128,0)">//qDebug() <<" table labled";</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">

<span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,128,0)">// row mod(26) = letter;</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">QWidget</span><span style="color:rgb(192,192,192)"> </span>*<span style="color:rgb(192,192,192)"> </span>thisPage<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">pageStack</span>->currentWidget();</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">QGraphicsView</span><span style="color:rgb(192,192,192)"> </span>*<span style="color:rgb(192,192,192)"> </span>thePage<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">dynamic_cast</span><<span style="color:rgb(128,0,128)">QGraphicsView</span>*>(thisPage);</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">QGraphicsScene</span><span style="color:rgb(192,192,192)"> </span>*<span style="color:rgb(192,192,192)"> </span>thisScene<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>thePage->scene();</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span>qDebug()<span style="color:rgb(192,192,192)"> </span><<<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"scene aquired "</span>;</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">QFocusFrame</span><span style="color:rgb(192,192,192)"> </span>*<span style="color:rgb(192,192,192)"> </span>tableProxy<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">new</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QFocusFrame</span>(newTable);</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span>thisScene->addWidget(newTable);</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">

<span style="color:rgb(192,192,192)">    </span>qDebug()<span style="color:rgb(192,192,192)"> </span><<<span style="color:rgb(0,128,0)">"table added"</span>;</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">

<span style="color:rgb(192,192,192)">    </span>qDebug()<span style="color:rgb(192,192,192)"> </span><<<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"new frame"</span>;</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,128,0)">//tableProxy->setWidget(newTable);</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">

<span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,128,0)">//qDebug()<< "set widgit";</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span>tableProxy-><span style="font-style:italic">setVisible</span>(<span style="color:rgb(128,128,0)">true</span>);</pre>



<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span>qDebug()<<<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"set visible"</span>; </pre>



</div>
<br>_______________________________________________<br>
Interest mailing list<br>
<a href="mailto:Interest@qt-project.org">Interest@qt-project.org</a><br>
<a href="http://lists.qt-project.org/mailman/listinfo/interest" target="_blank">http://lists.qt-project.org/mailman/listinfo/interest</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Josiah Bryan<br>765-215-0511<br><a href="mailto:josiahbryan@gmail.com" target="_blank">josiahbryan@gmail.com</a><br>