예제 #1
0
void ObjectsScene::configurePrinter(QPrinter *printer)
{
  if(!printer)
    throw Exception(ERR_OPR_NOT_ALOC_OBJECT ,__PRETTY_FUNCTION__,__FILE__,__LINE__);

  if(paper_size!=QPrinter::Custom)
   printer->setPaperSize(paper_size);
  else
  {
    #if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
      //The QTBUG-33645 is fixed on Qt 5.3
      QPageLayout pl;
      QPageSize ps;
      ps=QPageSize(QSizeF(custom_paper_size.width(), custom_paper_size.height()), QPageSize::Point, QString(), QPageSize::ExactMatch);
      pl.setPageSize(ps);
      pl.setOrientation(page_orientation==QPrinter::Landscape ? QPageLayout::Landscape : QPageLayout::Portrait);
      printer->setPageSize(pl.pageSize());
    #else
      #warning "Custom page size bug (QTBUG-33645) workaround for Qt 5.2 or lower. NOTE: This issue is fixed on Qt 5.3"
      printer->setPaperSize(QSizeF(custom_paper_size.height(), custom_paper_size.width()), QPrinter::Point);
    #endif
  }

  if(paper_size==QPrinter::Custom)
  {
    if(custom_paper_size.width() > custom_paper_size.height())
      ObjectsScene::page_orientation=QPrinter::Landscape;
    else
      ObjectsScene::page_orientation=QPrinter::Portrait;
  }
  else
     printer->setOrientation(page_orientation);

  printer->setPageMargins(page_margins.left(), page_margins.top(), page_margins.width(), page_margins.height(), QPrinter::Millimeter);
}
예제 #2
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    engine = new QQmlApplicationEngine();
    QPageLayout appWindow;
    appWindow.setOrientation(QPageLayout::Landscape);
    translator.load("translation_en.ts");
    app.installTranslator(&translator);
    sourceFile = "qrc:/main.qml";
    sourceUrl = QUrl(sourceFile);
    engine->load( QUrl(sourceUrl ) );
 //   MainApi *mA = new MainApi(viewer.rootContext());
    jobTimeClock = new TimeClock();
    return app.exec();
}