Some clarification on qtableview cell geometry needed
-
Hi,
trying to taylor the stardelegate example to my needs, I'm struggling to get the geometry right. I created a rather simple shape (reminding of a wand) to replace the stars.
But, I guess, the procedure for creating the wand is a little too complicated for a qtableview cell or something like that. I filled to vector with cosine and sine values respectively to draw some radial rays so to say:
QPen pen(Qt::black, 0.15); //in order to replace painter->drawPolygon(starPolygon, Qt::WindingFill); painter->setPen(pen); int h = rect.height() / (2 * PaintingScaleFactor); int w = rect.width() / (2 * PaintingScaleFactor); painter->translate(h, w); double grad = 135; painter->rotate(grad); for (unsigned int j=0; j<kosinusvec.size(); ++j) { QLineF l; l.setLine(kosinusvec[j], sinusvec[j], kosinusvec[j]*1.5, sinusvec[j])*1.5; painter->drawLine(l); }This worked quite well for drawing on a single widget. But does seem to involve too much transformation for a viable result in a qtableview, I suppose.
Should I produce a image beforehand and then fit it into the cell or rather parts of it?
Kind regards,
Andreas
Edit: typos
-
To be clear: The shape is being drawn but a few lines down on the qtableview. So there must be something wrong with the coordinates.
@andi456 said in Some clarification on qtableview cell geometry needed:
there must be something wrong with the coordinates.
painter->rotate(135);
Yes, you rotate the already translated painter so everything is painted down right
-
Ok, got rid of the transformations (rotate and translate), which does give better results, which still need some tinkering, however.
After some fiddling with the drawing, I finally got an acceptable result. Avoiding transformations seems to be a good advice, when it comes to drawings in table cells and similar entities.
-
A andi456 has marked this topic as solved on