void ribi::braw::QtPrintRatingDialog::Print(const std::string& filename)
{
    QPrinter printer;
    printer.setOrientation(QPrinter::Portrait);
    printer.setPaperSize(QPrinter::A4);
    printer.setFullPage(false);
    printer.setOutputFileName(filename.c_str());

    //Draw the image to painter to printer (?must be done before printing)
    QPainter painter;

    painter.begin(&printer);
    {
        //Collect widgets to print
        const std::vector<QWidget *> widgets = CollectWidgets();

        int y = 0;
        for (QWidget * const widget: widgets)
        {
            const int h = widget->height();
            if (y+h > painter.window().height())
            {
                printer.newPage();
                y = 0;
            }
            widget->render(&painter,QPoint(0,y));
            y+=h;
        }
    }
    painter.end();

}
void ribi::pvdb::QtPvdbPrintRatingDialog::Print()
{
  //Start save dialog
  const boost::shared_ptr<QFileDialog> print_dialog(
    pvdb::QtFileDialog::GetSaveFileDialog(
      pvdb::QtFileDialog::FileType::pdf));
  print_dialog->setWindowTitle("Exporteer document naar PDF");
  if (print_dialog->exec() != QDialog::Accepted
    || print_dialog->selectedFiles().empty() )
  {
    return;
  }
  assert(!print_dialog->selectedFiles().empty());
  assert(print_dialog->selectedFiles().size() == 1);
  const std::string filename = print_dialog->selectedFiles()[0].toStdString();

  QPrinter printer;
  printer.setOrientation(QPrinter::Portrait);
  printer.setPaperSize(QPrinter::A4);
  printer.setFullPage(false);
  printer.setOutputFileName(filename.c_str());

  //Draw the image to painter to printer (?must be done before printing)
  QPainter painter;

  painter.begin(&printer);
  {
    //Collect widgets to print
    const std::vector<QWidget *> widgets = CollectWidgets();

    int y = 0;
    for (QWidget * const widget: widgets)
    {
      const int h = widget->height();
      if (y+h > painter.window().height())
      {
        printer.newPage();
        y = 0;
      }
      widget->render(&painter,QPoint(0,y));
      y+=h;
    }
  }
  painter.end();

}