Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Incorrect Scene Size Dimensions when called from Custom QGraphicsWidget
Forum Updated to NodeBB v4.3 + New Features

Incorrect Scene Size Dimensions when called from Custom QGraphicsWidget

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 489 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    oracle3001
    wrote on last edited by
    #1

    I have the following simple setup,

    @int main(int argc, char argv[])
    {
    QApplication app(argc, argv);
    QGraphicsScene
    scene = new QGraphicsScene();
    QCustomGraphicsView* customGraphicsView= new QCustomGraphicsView(scene) ;
    overlayWidget->setSceneRect(0,0,overlayWidget->geometry().width(),overlayWidget->geometry().height());

    QCustomGraphicsWidget* customWidget = new QCustomGraphicsWidget();
    scene->addItem(customWidget) ;
    
    customGraphicsView->show() ;
    return app.exec();
    

    }@

    QCustomGraphicsView size is set within its own constructor (and is based up a larger window). It doesn't have a frame and scrollbars are disabled.

    In QCustomGraphicsWidget...

    @void QCustomGraphicsWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
    {

    QGraphicsWidget::mouseMoveEvent(event); // move the item...
    
    qDebug(&#41; << QString("Mouse Move Event"&#41; ;
    QRectF sceneRect = scene()->sceneRect() ;
    qDebug("geo: %f %f", sceneRect .width(), sceneRect .height());
    

    }
    @

    And the sceneRect variable does not return the correct size of the scene that it has been added to.

    What I am trying to do, is enforce that when my QCustomGraphicsWidget is moved around the scene that when it gets to the edge, it can't be dragged beyond that and out of sight.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved