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. Moving QRegion
Forum Updated to NodeBB v4.3 + New Features

Moving QRegion

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 239 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.
  • S Offline
    S Offline
    skylendar
    wrote on last edited by
    #1

    hi there and thx for reading and answering this post if you can

    I'm drawing in a QWidget with a QPainter Qp. Once done, I want to move the right part of my drawing to the left.

    So, I wrote:

    QRect r(width, 0, width + 100 , height);
    r.moveLeft(0);
    Qp->setClipping(true);
    Qp->setClipRect(r, Qt::ReplaceClip);

    But noting happens. What's wrong ?

    Christian EhrlicherC 1 Reply Last reply
    0
    • S skylendar

      hi there and thx for reading and answering this post if you can

      I'm drawing in a QWidget with a QPainter Qp. Once done, I want to move the right part of my drawing to the left.

      So, I wrote:

      QRect r(width, 0, width + 100 , height);
      r.moveLeft(0);
      Qp->setClipping(true);
      Qp->setClipRect(r, Qt::ReplaceClip);

      But noting happens. What's wrong ?

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @skylendar said in Moving QRegion:

      But noting happens. What's wrong ?

      What should happen? You don't draw anything.
      Please provde a minimal, compilable example.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        QRect::moveLeft just changes coordinates of the rectangle. It doesn't know what you use that rectangle for and certainly doesn't do any image editing.
        Clipping doesn't move anything either. Those are bounds for painting that occurs after you set it.

        You can either redraw your thing at the new location or directly manipulate the underlying data of whatever paint device you're drawing on if it allows it.

        1 Reply Last reply
        0
        • Ronel_qtmasterR Offline
          Ronel_qtmasterR Offline
          Ronel_qtmaster
          wrote on last edited by
          #4

          @skylendar you can use QPainter alongside QTransform
          First thing is to translate the painter, then draw your rectangle
          an exemple

            QPainter painter(this);
            QTransform transform;
            transform.translate(50, 50);
            painter.setPen(QPen(Qt::blue, 1, Qt::DashLine));
            painter.setTransform(transform);
            painter.drawRect(0, 0, 100, 100);
          

          hope it helps

          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