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. Difficulty to show only what I want in QGraphicsview
Forum Updated to NodeBB v4.3 + New Features

Difficulty to show only what I want in QGraphicsview

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

    Hello every one.

    Im using Qtcreator 2.0, and Im having difficulty to show only what I placed in the Scene.
    My code is like that:

    @
    ui->graphicsView->setScene(new QGraphicsScene());
    QPolygon Polygon;
    Polygon.append(QPoint(1,1));
    Polygon.append(QPoint(1,2));
    Polygon.append(QPoint(2,2));
    Polygon.append(QPoint(2,1));
    ui->graphicsView->scene()->addPolygon(Polygon);
    ui->graphicsView->fitInView(ui->graphicsView->items().at(0),Qt::KeepAspectRatio);
    @

    The Polygone that Im inserting is showed better when it run the last command. but it still small in the QGraphicsview

    Anyone knows how to solve this?

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      Hi,
      @
      ui->graphicsView->fitInView(ui->graphicsView->items().at(0),Qt::KeepAspectRatio);
      @

      instead of that, I think you can directly use view->setTransform() or view->scale()

      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