[Interest] floating table in graphics view

Nehemiah Dacres vivacarlie at gmail.com
Wed Aug 15 17:43:24 CEST 2012


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";
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120815/12516cfa/attachment.html>


More information about the Interest mailing list