[Interest] floating table in graphics view

Josiah Bryan josiahbryan at gmail.com
Wed Aug 15 19:14:16 CEST 2012


To get "regular" items movable, you have to set ItemIsMovable 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....

On Wed, Aug 15, 2012 at 11:43 AM, Nehemiah Dacres <vivacarlie at gmail.com>wrote:

> 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
>
> void MainWindow::on_actionAddTable_triggered()
>
> {
>
>     //add table
>
>     QTableWidget* newTable = new QTableWidget( 3, 3);
>
>     //newTable->setHorizontalHeaderLabels(QStringList()<<"1"<<"2"<<"3");
>
>     //newTable->setVerticalHeaderLabels(QStringList()<<"A"<<"B"<<"C");
>
>     //qDebug() <<" table labled";
>
>     // row mod(26) = letter;
>
>     QWidget * thisPage = pageStack->currentWidget();
>
>     QGraphicsView * thePage = dynamic_cast<QGraphicsView*>(thisPage);
>
>     QGraphicsScene * thisScene = thePage->scene();
>
>     qDebug() << "scene aquired ";
>
>     thisScene->addWidget(newTable);
>
>     qDebug() <<"table added";
>
>     QFocusFrame * tableProxy = new QFocusFrame();
>
>     qDebug() << "new frame";
>
>     tableProxy->setWidget(newTable);
>
>     qDebug()<< "set widgit";
>
>     tableProxy->setVisible(true);
>
>     qDebug()<< "set widgit";
>
>
> }
>
> and it crashes after qDebug outputs set widgit, mean time so does this
>
> void MainWindow::on_actionAddTable_triggered()
>
> {
>
>     //add table
>
>     QTableWidget* newTable = new QTableWidget( 3, 3);
>
>     //newTable->setHorizontalHeaderLabels(QStringList()<<"1"<<"2"<<"3");
>
>     //newTable->setVerticalHeaderLabels(QStringList()<<"A"<<"B"<<"C");
>
>     //qDebug() <<" table labled";
>
>     // row mod(26) = letter;
>
>     QWidget * thisPage = pageStack->currentWidget();
>
>     QGraphicsView * thePage = dynamic_cast<QGraphicsView*>(thisPage);
>
>     QGraphicsScene * thisScene = thePage->scene();
>
>     qDebug() << "scene aquired ";
>
>     QFocusFrame * tableProxy = new QFocusFrame(newTable);
>
>     thisScene->addWidget(newTable);
>
>     qDebug() <<"table added";
>
>     qDebug() << "new frame";
>
>     //tableProxy->setWidget(newTable);
>
>     //qDebug()<< "set widgit";
>
>     tableProxy->setVisible(true);
>
>     qDebug()<< "set visible";
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>


-- 
Josiah Bryan
765-215-0511
josiahbryan at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120815/c8176191/attachment.html>


More information about the Interest mailing list