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. Draw big things with Painter outside main window.

Draw big things with Painter outside main window.

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 612 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.
  • B Offline
    B Offline
    BD9a
    wrote on last edited by
    #1

    Hey, is it possible to draw things outside main window? I have an really big pattern to draw but I cant because of it's too big / window is too small. Is it possible?

    jsulmJ 1 Reply Last reply
    0
    • B BD9a

      Hey, is it possible to draw things outside main window? I have an really big pattern to draw but I cant because of it's too big / window is too small. Is it possible?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @BD9a You can only draw on a widget, so, no you can't draw outside of your window. Why would you need to draw outside of the window? Just draw what currently fits in your window.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        Yes it is possible if you use a QPixmap.

        https://forum.qt.io/topic/108442/how-to-paint-to-pixmap/2

        But if it is to show to the user, then you should either use a ScrollArea so the user can scroll around to see if all
        or simply draw in a scaled version that fits the window.

        1 Reply Last reply
        1
        • jsulmJ jsulm

          @BD9a You can only draw on a widget, so, no you can't draw outside of your window. Why would you need to draw outside of the window? Just draw what currently fits in your window.

          B Offline
          B Offline
          BD9a
          wrote on last edited by
          #4

          @jsulm The problem is that sometimes my pattern is a lot bigger than window (I have an "ScrollArea / Drag option to see it all)

          @mrjj Will test this QPixmap, thanks. As I said I have an "ScrollArea / Drag option to see it all, but what about "scaled version"? I saw there's Painter->setScale(), but it doesnt work for me properly(?) (cant see "image" after that option)

          mrjjM 1 Reply Last reply
          0
          • B BD9a

            @jsulm The problem is that sometimes my pattern is a lot bigger than window (I have an "ScrollArea / Drag option to see it all)

            @mrjj Will test this QPixmap, thanks. As I said I have an "ScrollArea / Drag option to see it all, but what about "scaled version"? I saw there's Painter->setScale(), but it doesnt work for me properly(?) (cant see "image" after that option)

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @BD9a

            Hi
            How do you currently draw the pattern

            B 1 Reply Last reply
            0
            • mrjjM mrjj

              @BD9a

              Hi
              How do you currently draw the pattern

              B Offline
              B Offline
              BD9a
              wrote on last edited by
              #6

              @mrjj

              Im using painter->drawPoint(row, col); in loop (looping through file containing data) in a paint() function (from QQuickPaintedItem).

              mrjjM 1 Reply Last reply
              0
              • B BD9a

                @mrjj

                Im using painter->drawPoint(row, col); in loop (looping through file containing data) in a paint() function (from QQuickPaintedItem).

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @BD9a
                Hi
                Well drawpoint is affected by scale() so maybe the scale values was just too much

                virtual void paintEvent(QPaintEvent *event) override
                    {
                        QPainter p(this);
                        QPointF list[] = {{0,0}, {20,20}, {30,30}};
                        p.setPen(QPen(Qt::red));
                        p.scale(0.5,0.5);
                        p.drawPoints(list,3);
                    }
                

                clearly makes the half the size but maybe your use case if differnt.

                B 1 Reply Last reply
                0
                • mrjjM mrjj

                  @BD9a
                  Hi
                  Well drawpoint is affected by scale() so maybe the scale values was just too much

                  virtual void paintEvent(QPaintEvent *event) override
                      {
                          QPainter p(this);
                          QPointF list[] = {{0,0}, {20,20}, {30,30}};
                          p.setPen(QPen(Qt::red));
                          p.scale(0.5,0.5);
                          p.drawPoints(list,3);
                      }
                  

                  clearly makes the half the size but maybe your use case if differnt.

                  B Offline
                  B Offline
                  BD9a
                  wrote on last edited by
                  #8

                  @mrjj
                  In QQuickPaintedItem there's no paintEvent that I can override. If it does matter, Im using C++ Object in QML to display it.

                  mrjjM 1 Reply Last reply
                  0
                  • B BD9a

                    @mrjj
                    In QQuickPaintedItem there's no paintEvent that I can override. If it does matter, Im using C++ Object in QML to display it.

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @BD9a

                    I'm don't think it matter since QQuickPaintedItem has paint.

                    But did you try to with like scale (0.5,0.5) and see if that affects it ?

                    B 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @BD9a

                      I'm don't think it matter since QQuickPaintedItem has paint.

                      But did you try to with like scale (0.5,0.5) and see if that affects it ?

                      B Offline
                      B Offline
                      BD9a
                      wrote on last edited by
                      #10

                      @mrjj
                      Yeah, when I had problem with this I placed painter->scale(0.5, 0.5); in loop, I dont know why. Now I placed it before loop and it's working, but the problem is when the pattern is small. When I tried to "back" to original scale in QML (from 0.5 in C++ to 2.0 in QML) the image is blurry. I will try to do pattern size detection and then - if pattern is big scale is down, if pattern is small then do nothing / scale it up.

                      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