Displaying QRCode on HbQt Application Interface

32 views
Skip to first unread message

Pritpal Bedi

unread,
Aug 13, 2023, 2:27:19 AM8/13/23
to QtContribs
  Hello Everybody

Here is the simplest solution from HbQt's stand-point.

....
....
oUI:labelQrCode():setPixmap( GenerateQrCode( "https://www.vouch.in" )
.....

FUNCTION GenerateQRCode( cCode )
   LOCAL hZebra   := hb_zebra_create_qrcode( cCode )
   LOCAL oBrush   := QBrush( QColor( 0, 0, 0 ) )
   LOCAL oImage   := QImage( QSize( 66, 66 ), QImage_Format_RGB32 )
   LOCAL oPainter, oPixmap

   oImage:fill( QColor( Qt_white ) )
   oPainter := QPainter( oImage )
   
   hb_zebra_draw( hZebra, {| x, y, w, h | oPainter:fillRect( Int( x + .5 ), Int( y + .5 ), Int( w + .5 ), Int( h + .5 ), oBrush ) }, 1, 1, 3, 3 )
   oPixmap := QPixmap():fromImage( oImage )

   RETURN oPixmap
   

Pritpal Bedi
a student of software analysis & concepts

Reply all
Reply to author
Forward
0 new messages