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. QPainter zero point bug
Forum Updated to NodeBB v4.3 + New Features

QPainter zero point bug

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt 5.9.0qpainter
2 Posts 2 Posters 657 Views 1 Watching
  • 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
    goldstar2154
    wrote on last edited by
    #1

    So here is the code

    void SButton::paintEvent(QPaintEvent* event)
    {
    	QPushButton::paintEvent(event);
    
    	if (m_strikeout == true)
    	{
    		QPainter painter;
    		painter.begin(this);
    		painter.setPen(QColor(0, 0, 0));
    		QRectF br = rect();
    		br.adjust(m_margin_left, m_margin_top, -m_margin_right, -m_margin_bottom - m_o_label->size().height());
    		painter.drawRect(br);
    		painter.end();
    	}
    }
    

    br is 19;19;341;251

    here screens from 2 different PCs with SAME version of windows/directX ..., but with different hardware (processor and video)
    First:
    1_1551455944982_pc_2.png
    Second:
    0_1551455944981_pc_1.png

    Upper left point is 0;0 point of my SButton widget

    How does it works? i'm very confused

    I try change Qrect to QrectF, draw lines and other stuff, on second PC i always got +1px at height

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      kind of shooting in the dark here, but remember that the painter coordinate system can be scaled, rotated, and new origin set. Try explicitly defining the coordinate system...Also, if your coordinates are floating point then you have to deal with floating point roundoff error.

      1 Reply Last reply
      0

      • Login

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