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. QPainter and 2D Graphics
Qt 6.11 is out! See what's new in the release blog

QPainter and 2D Graphics

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.8k 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.
  • M Offline
    M Offline
    masayoshi
    wrote on last edited by
    #1

    Does this code work well? I can not compile it. (Qt 5.7.1)
    QPainter and 2D Graphics

    // 
    error: use of undeclared identifier 'engine'; did you mean 'inline'?
        if (engine)
            ^~~~~~
            inline
    
    jsulmJ 1 Reply Last reply
    0
    • M masayoshi

      Does this code work well? I can not compile it. (Qt 5.7.1)
      QPainter and 2D Graphics

      // 
      error: use of undeclared identifier 'engine'; did you mean 'inline'?
          if (engine)
              ^~~~~~
              inline
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @masayoshi From a quick view on that example engine wasn't declared anywhere. You can simply change it like this:

      if (engine)
        painter.begin(engine);
      else
        painter.begin(this);
      

      to

        painter.begin(this);
      

      Is it possible to download source code for the examples there?
      You should ask authors of the book.

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

      M 2 Replies Last reply
      1
      • jsulmJ jsulm

        @masayoshi From a quick view on that example engine wasn't declared anywhere. You can simply change it like this:

        if (engine)
          painter.begin(engine);
        else
          painter.begin(this);
        

        to

          painter.begin(this);
        

        Is it possible to download source code for the examples there?
        You should ask authors of the book.

        M Offline
        M Offline
        masayoshi
        wrote on last edited by masayoshi
        #3

        @jsulm said in QPainter and 2D Graphics:

        @masayoshi From a quick view on that example engine wasn't declared anywhere. You can simply change it like this:

        if (engine)
          painter.begin(engine);
        else
          painter.begin(this);
        

        to

          painter.begin(this);
        

        Is it possible to download source code for the examples there?
        You should ask authors of the book.

        After doing that, I can compile it.
        When I save image to SVG, I get the following error.

        //your code here
        QWidget::paintEngine: Should no longer be called
        QPainter::begin: Paint device returned engine == 0, type: 1
        QPainter::end: Painter not active, aborted
        
        mrjjM 1 Reply Last reply
        0
        • M masayoshi

          @jsulm said in QPainter and 2D Graphics:

          @masayoshi From a quick view on that example engine wasn't declared anywhere. You can simply change it like this:

          if (engine)
            painter.begin(engine);
          else
            painter.begin(this);
          

          to

            painter.begin(this);
          

          Is it possible to download source code for the examples there?
          You should ask authors of the book.

          After doing that, I can compile it.
          When I save image to SVG, I get the following error.

          //your code here
          QWidget::paintEngine: Should no longer be called
          QPainter::begin: Paint device returned engine == 0, type: 1
          QPainter::end: Painter not active, aborted
          
          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @masayoshi
          Can you show the code that saves ?
          It seems like you are using a QPainter outside the Paint function which is not supported.

          M 1 Reply Last reply
          0
          • mrjjM mrjj

            @masayoshi
            Can you show the code that saves ?
            It seems like you are using a QPainter outside the Paint function which is not supported.

            M Offline
            M Offline
            masayoshi
            wrote on last edited by
            #5

            @mrjj said in QPainter and 2D Graphics:

            @masayoshi
            Can you show the code that saves ?
            It seems like you are using a QPainter outside the Paint function which is not supported.

            Chapter 3. QPainter and 2D Graphics

            I only used this code. I used Qt 5.7

            1 Reply Last reply
            0
            • jsulmJ jsulm

              @masayoshi From a quick view on that example engine wasn't declared anywhere. You can simply change it like this:

              if (engine)
                painter.begin(engine);
              else
                painter.begin(this);
              

              to

                painter.begin(this);
              

              Is it possible to download source code for the examples there?
              You should ask authors of the book.

              M Offline
              M Offline
              masayoshi
              wrote on last edited by masayoshi
              #6

              @jsulm said in QPainter and 2D Graphics:

              Is it possible to download source code for the examples there?
              You should ask authors of the book.

              Thank you. I read book carefully. I got source code. It works on my computer.
              I will look it up carefully.

              // Source code
              
                  if (generator)
                      painter.begin(generator);
                  else
                      painter.begin(this);
              
              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