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. QgraphicsView not align to center if setFixedSize
Qt 6.11 is out! See what's new in the release blog

QgraphicsView not align to center if setFixedSize

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.7k 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.
  • G Offline
    G Offline
    GoldenAxe
    wrote on last edited by
    #1

    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
    0

    • Login

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