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. Some clarification on qtableview cell geometry needed

Some clarification on qtableview cell geometry needed

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 342 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.
  • A Offline
    A Offline
    andi456
    wrote on last edited by andi456
    #1

    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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andi456
      wrote on last edited by
      #2

      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.

      Christian EhrlicherC 1 Reply Last reply
      0
      • A andi456

        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.

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @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

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        1
        • A Offline
          A Offline
          andi456
          wrote on last edited by andi456
          #4

          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.

          1 Reply Last reply
          0
          • A andi456 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