Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-26564

All child widgets not rendered to PDF

    XMLWordPrintable

Details

    • 071098b08b12fc1af6341ff6d7ba6713e5de1481 (5.3)

    Description

      The attached example application demonstrates the use case.

      Use case:

      Widget has some child widgets on the layout.
      Render the widget into the QPicture.
      Render the QPicture to the printer:

      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent)
      {
      
          widget = new QWidget;
          QGridLayout *layout = new QGridLayout(widget);
          layout->addWidget( new QRadioButton("Radio button"), 0,0 );
          layout->addWidget( new QLabel("Label"), 0,1 );
          layout->addWidget( new QPushButton( "Button 1" ), 1,0 );
          layout->addWidget( new QPushButton("Button 2"), 1,1 );
      
          setCentralWidget(widget);
          QTimer::singleShot(2000, this, SLOT(pic()));
      }
      
      void MainWindow::pic()
      {
          qDebug("MainWindow::pic()");
      
          QPicture pic;
          widget->render(&pic); // render to QPicture
          QPrinter printer;
          printer.setOutputFileName( "test.pdf" );
          QPainter painter(&printer);
          pic.play(&painter); // render QPicture to printer.
      }
      

      Error: only the last added child widget is visible on the generated PDF.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              laknoll Lars Knoll
              qtcomsupport Qt Support
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes