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. How to align to the a rectangle to the left of a QGraphicsView without scaling the scene?

How to align to the a rectangle to the left of a QGraphicsView without scaling the scene?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 621 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.
  • aarelovichA Offline
    aarelovichA Offline
    aarelovich
    wrote on last edited by
    #1

    Here is what I wat to do.

    I need to draw in a QGraphicsView a series of rectangles that are aligned left and right. By this I mean that if rectangle i has posion (0,y) rectangle i+1 needs to have position (0,max) where max is such that the right side of the rectangle "touches" the right side of the QGraphicsView.

    When the window is resized I need to recalculate the value of max such that the rectangle is always touching the right side of the screen.

    Here is how I add my scene (this references a class that inherits QGraphicsView)

    scene = new QGraphicsScene(this);
    this->setScene(scene);
    this->setAlignment(Qt::AlignTop|Qt::AlignLeft);
    

    To add a rectangle that touches the left border I add it a (0,yvalue,width,height).

    How do I calculate the value of X so that that the rectangle will touch the right border?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you thinking about something like x = scene->width() - rect->width() ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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