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. QMainWindow.resize prevent QGraphicsView.resize

QMainWindow.resize prevent QGraphicsView.resize

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 571 Views
  • 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.
  • sonichyS Offline
    sonichyS Offline
    sonichy
    wrote on last edited by
    #1

    QMainWindow.resize will auto resize QGraphicsView to fit parent, how to prevent ?

    void MainWindow::open(QString filepath)
    {
        scene->clear();
        QPixmap pixmap(filepath);
        QGraphicsPixmapItem *GPI = scene->addPixmap(pixmap);
        GPI->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
        scene->setSceneRect(0, 0, pixmap.width(), pixmap.height());
        ui->graphicsView->resize(pixmap.size());
    }
    

    https://github.com/sonichy

    KillerSmathK 1 Reply Last reply
    0
    • sonichyS sonichy

      QMainWindow.resize will auto resize QGraphicsView to fit parent, how to prevent ?

      void MainWindow::open(QString filepath)
      {
          scene->clear();
          QPixmap pixmap(filepath);
          QGraphicsPixmapItem *GPI = scene->addPixmap(pixmap);
          GPI->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
          scene->setSceneRect(0, 0, pixmap.width(), pixmap.height());
          ui->graphicsView->resize(pixmap.size());
      }
      
      KillerSmathK Offline
      KillerSmathK Offline
      KillerSmath
      wrote on last edited by
      #2

      @sonichy
      If your QGraphicsView is inside a QLayout, this layout automatically position and resize all child widgets.
      But you can break the resize feature by setup a fixed Size of a widget.

      setFixedHeight(int h)
      setFixedWidth(int w)
      setFixedSize(const QSize &s)
      setFixedSize(int w, int h)

      @Computer Science Student - Brazil
      Web Developer and Researcher
      “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

      sonichyS 1 Reply Last reply
      5
      • KillerSmathK KillerSmath

        @sonichy
        If your QGraphicsView is inside a QLayout, this layout automatically position and resize all child widgets.
        But you can break the resize feature by setup a fixed Size of a widget.

        setFixedHeight(int h)
        setFixedWidth(int w)
        setFixedSize(const QSize &s)
        setFixedSize(int w, int h)

        sonichyS Offline
        sonichyS Offline
        sonichy
        wrote on last edited by sonichy
        #3

        @KillerSmath Yes, child widget with no layout will be not auto resize with parent !
        But the scrollbar do not display !

        https://github.com/sonichy

        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