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 text and numbers in dot matrix format

Draw text and numbers in dot matrix format

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

    Hi.

    Having to draw some text and numbers in graphic form (see below for an example), is there an easy way to do it?

    Screenshot_20230618_143822.png

    .

    A question about the QPainterPath object,

    path.moveTo( 22, 7 );
    path.lineTo( 22, 7 );

    should it draw a one point line or draw nothing?

    Pl45m4P M 2 Replies Last reply
    0
    • G giusdbg

      Hi.

      Having to draw some text and numbers in graphic form (see below for an example), is there an easy way to do it?

      Screenshot_20230618_143822.png

      .

      A question about the QPainterPath object,

      path.moveTo( 22, 7 );
      path.lineTo( 22, 7 );

      should it draw a one point line or draw nothing?

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @giusdbg said in Draw text and numbers in dot matrix format:

      should it draw a one point line or draw nothing?

      Nothing, I would say. You move the painter to (22, 7) ( = make this the current position) and then start to draw a "line" from (22, 7) to (22, 7)

      Having to draw some text and numbers in graphic form (see below for an example), is there an easy way to do it?

      What about the QGraphicsView framework?

      • https://doc.qt.io/qt-6/graphicsview.html

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      G 1 Reply Last reply
      1
      • G giusdbg

        Hi.

        Having to draw some text and numbers in graphic form (see below for an example), is there an easy way to do it?

        Screenshot_20230618_143822.png

        .

        A question about the QPainterPath object,

        path.moveTo( 22, 7 );
        path.lineTo( 22, 7 );

        should it draw a one point line or draw nothing?

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

        @giusdbg
        Hi,
        You can embed a custom font to your app.
        https://www.1001freefonts.com/dotted-fonts.php

        1 Reply Last reply
        2
        • Pl45m4P Pl45m4

          @giusdbg said in Draw text and numbers in dot matrix format:

          should it draw a one point line or draw nothing?

          Nothing, I would say. You move the painter to (22, 7) ( = make this the current position) and then start to draw a "line" from (22, 7) to (22, 7)

          Having to draw some text and numbers in graphic form (see below for an example), is there an easy way to do it?

          What about the QGraphicsView framework?

          • https://doc.qt.io/qt-6/graphicsview.html
          G Offline
          G Offline
          giusdbg
          wrote on last edited by giusdbg
          #4

          @Pl45m4 Yes, but if it works like this how do you draw a point?

          My problem is that I converted a text draw from qt3 to qt4, and it all works, the dimensions are all right (not a pixel less), it just doesn't draw a one point line.

          I printed the values used in moveTo and lineTo, and they are identical.

          Ignore the abstruse calculations,

          qt3

          void QLcd::drawSegment(QPainter *p,const int *c, int x, int y, int w, int h)
          {
           h--;
            
           p->moveTo( x+(c[0]*w)/2 , y+(c[1]*h)/4 );
           c+= 2;
           do {   
               p->lineTo( x+(c[0]*w)/2 , y+(c[1]*h)/4 );
               c+= 2;
           } while(*c>=0);
          }
          

          qt4

          void QLcd::drawSegment(QPainter *p,const int *c, int x, int y, int w, int h)
          {
           h--;
           
            QPainterPath path;
              
            path.moveTo (x+(c[0]*w)/2 , y+(c[1]*h)/4);
             
           c+= 2;
           do {   
              path.lineTo( x+(c[0]*w)/2 , y+(c[1]*h)/4 );     
                     
               c+= 2;
           } while(*c>=0);
           
             p->drawPath( path );
          }
          
          
          M 1 Reply Last reply
          0
          • G giusdbg

            @Pl45m4 Yes, but if it works like this how do you draw a point?

            My problem is that I converted a text draw from qt3 to qt4, and it all works, the dimensions are all right (not a pixel less), it just doesn't draw a one point line.

            I printed the values used in moveTo and lineTo, and they are identical.

            Ignore the abstruse calculations,

            qt3

            void QLcd::drawSegment(QPainter *p,const int *c, int x, int y, int w, int h)
            {
             h--;
              
             p->moveTo( x+(c[0]*w)/2 , y+(c[1]*h)/4 );
             c+= 2;
             do {   
                 p->lineTo( x+(c[0]*w)/2 , y+(c[1]*h)/4 );
                 c+= 2;
             } while(*c>=0);
            }
            

            qt4

            void QLcd::drawSegment(QPainter *p,const int *c, int x, int y, int w, int h)
            {
             h--;
             
              QPainterPath path;
                
              path.moveTo (x+(c[0]*w)/2 , y+(c[1]*h)/4);
               
             c+= 2;
             do {   
                path.lineTo( x+(c[0]*w)/2 , y+(c[1]*h)/4 );     
                       
                 c+= 2;
             } while(*c>=0);
             
               p->drawPath( path );
            }
            
            
            M Offline
            M Offline
            mpergand
            wrote on last edited by mpergand
            #5

            @giusdbg
            Use addRect or addEllipse.
            That's what I'm doing here:
            https://forum.qt.io/post/688908

            G 1 Reply Last reply
            2
            • M mpergand

              @giusdbg
              Use addRect or addEllipse.
              That's what I'm doing here:
              https://forum.qt.io/post/688908

              G Offline
              G Offline
              giusdbg
              wrote on last edited by
              #6

              @mpergand @Pl45m4 Works, thanks.
              But I still had to do a trick, when the start and end point is the same, sum 0.1 to the end point.

              .

              I'll try the framework and font suggestions in the project review phase, which I definitely need to do.
              (The qt4 port must work fine first, probably in the qt5/6 port).

              1 Reply Last reply
              0
              • G giusdbg has marked this topic as solved on

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved