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. Strange problem with qpixmap printing in debug and release mode

Strange problem with qpixmap printing in debug and release mode

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 438 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.
  • ZgemboZ Offline
    ZgemboZ Offline
    Zgembo
    wrote on last edited by
    #1

    Hi all,

    I am working on a project that is developed in visual studio 2017. I am having some strange issues with printing of qpixmap header. This is the code that I use to generate header for my print job.

    //Construct header pixmap
    	headerPixmap = new QPixmap(pageSize.width(), headerHeight);
    	QPainter *headerPainter = new QPainter(headerPixmap);
    	headerPainter->setPen(*(new QColor(Qt::black)));
    	headerPainter->drawRect(0, 0, headerPixmap->width() - 1, headerPixmap->height() - 1);
    	QFont font = headerPainter->font();
    	font.setPixelSize(12);
    	headerPainter->setFont(font);
    	QString headerText = printWidget->getPatient() + "     " + printWidget->getRecorded() + "  "+ printWidget->getPrinted() + "      " + printWidget->getSpeed();
    	headerPainter->drawText(20, 18, headerText);
    	//end
    

    When I print a document in debug mode everything looks fine, but when I print document in release mode my header is totally darkened. These are the printed documents.

    0_1555067073627_7ecd7fe7-2050-4ff5-9178-a2b2bb7e34e6-image.png

    Does anyone has any idea if I am missing something in release mode?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      When you say Release mode, do you mean when you run it standalone or do you
      still run it in Creator ?

      Also
      headerPainter->setPen(*(new QColor(Qt::black)));
      is not good.
      No reason to new it
      headerPainter->setPen( QPen(Qt::black) );

      1 Reply Last reply
      0
      • ZgemboZ Offline
        ZgemboZ Offline
        Zgembo
        wrote on last edited by
        #3

        I figured it out.
        I just hat to explicit set brush on qpainter and everything works.
        headerPainter->setBrush(Qt::lightGray);

        1 Reply Last reply
        2

        • Login

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