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. Printing with QCustomPlot
Forum Updated to NodeBB v4.3 + New Features

Printing with QCustomPlot

Scheduled Pinned Locked Moved Solved General and Desktop
1 Posts 1 Posters 1.3k 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.
  • B Offline
    B Offline
    BrianE
    wrote on 24 Feb 2016, 23:14 last edited by
    #1

    OK, so I thought I'd managed to grasp what to do but sadly it seems not. The following code gives me a preview dialogue (thankfully) but the area where I expect to see the plot is blank (plot is just ui->customplot). Please just point me in the right direction! I need a clue.

    void MainWindow::on_actionPreview_triggered()
    {
        // display print preview dialog
        QPrinter             myprinter( QPrinter::HighResolution );
        QPrintPreviewDialog  mypreview( &myprinter, this );
        connect( &mypreview, SIGNAL(paintRequested(QPrinter*)), SLOT(printfunction(QPrinter*)) );
        mypreview.exec();
    }
    
    void MainWindow::printfunction(QPrinter *aprinter)
    {
        // this is the actual put it on the page bit
        // create a PAINTER do the job
        QCPPainter mypainter(aprinter);
    
        // use the painter to create the page
        int      w = aprinter->pageRect().width();
        int      h = aprinter->pageRect().height();
    //    mypainter.begin(aprinter);
        plot->toPainter(&mypainter, w, h);
        mypainter.end();
    }
    
    
    1 Reply Last reply
    0

    1/1

    24 Feb 2016, 23:14

    • Login

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