Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    QgraphicsView not align to center if setFixedSize

    General and Desktop
    1
    1
    1587
    Loading More Posts
    • 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.
    • G
      GoldenAxe last edited by

      When I setFixedSize for my QgraphicsView he get align to the top left corner of the centralwidget, when I don't setFixeSize it's centered but the view is spread on the entire centralwidghet meaning if I set mouseMoveEvent to the (x,y) position it will work for the entire screen even the part of the screen which don't have any QGrpahicsItem paint on.

      some test code I was trying (I was trying to set it inside a layout as well):

      @m_mapView = new MapView(this);
      m_mapView->setObjectName("map");
      QGridLayout *mainLayout = new QGridLayout(this);
      mainLayout->addWidget(m_mapView);
      mainLayout->setAlignment(m_mapView, Qt::AlignCenter);
      setLayout(mainLayout);
      m_mapView->setAlignment(Qt::AlignCenter);
      //this->setCentralWidget(m_mapView);
      m_mapView->setFixedSize(wPixel, hPixel);@
      ....

      • mapView is a custom QGraphicsView, maybe I need to implement something there that will make it align to the center?
      • I know that the default align for QGraphicsView is center...but doesn't seems to work for me
      1 Reply Last reply Reply Quote 0
      • First post
        Last post