Wednesday 15 May 2013

c++ - Millimeter paper in QT -



c++ - Millimeter paper in QT -

i have paint millimeter grid on widget. existing class can help me that? need paint math charts.

please, help good. im stucked.

before reinventing wheel please take in business relationship charting libraries discussed here. both qcustomplot , qwt easy include , not hard customize. both provide several examples; perchance 1 of them solution addressing issue.

if available libraries don't fulfill needs can create own solution subclassing qwidget , reimplementing painevent(). qpainter , qpainterpath key classes task. qt provides lot of interesting tutorials, "basic drawing example" , "painter paths example". enjoy this simple example or this one. starting these references should able draw grid easily.

finally, graphics view framework contains qgraphicsscene (citing docs)

provides surface managing big number of 2d graphical items.

such class has been used charting purposes , grids, exploiting painting apis introduced above. while using class crucial, guarantee overall performance, draw grid in drawbackground() function done instance here (or utilize background bitmap).

all api discussed work in pixels. if concerned exact millimeters representation on screen, can exploit qscreen object, straight accessible qapp pointer. provides several functions, in particular physicaldotsperinch() (logicaldotsperinch() android since other returns infinite value on kitkat). pixel approximation millimeter can calculated follows:

int dotpermillimeter = qround(qapp->primaryscreen()->physicaldotsperinch() / 25.4)

c++ qt grid draw qwidget

No comments:

Post a Comment