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. Qt printer
Forum Updated to NodeBB v4.3 + New Features

Qt printer

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.2k 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.
  • G Offline
    G Offline
    ganeshgladish
    wrote on last edited by
    #1

    hi,

    how to send qml gui (as image) to qt-c++ ........because i want printing this gui ...please help me

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      why do open up a new thread instead of continuing the "old one":http://qt-project.org/forums/viewthread/28935/ ?

      I already gave an answer there...what's unclear to you of this solution?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • G Offline
        G Offline
        ganeshgladish
        wrote on last edited by
        #3

        i can't understand your example...because i don't know where and how to send my qml gui (like hello.qml file) to this qt c++ function...

        i have hello.qml gui
        like,

        Rectangle{
        id:gui
        width:100
        height:100
        color:"red"
        Text{
        id:text
        text:"Hello World"
        font.bold:true
        anchors.centerin:parent
        }
        MouseArea{
        anchors.fill: parent
        onClicked: myObject.print_pdf();
        }
        }

        i have created Qdeclarative view for sending data to c++ function..

        please see the mousearea function i have created onclicked finction,
        in this onclicked function i want to send hello.qml to c++(print_pdf() function) ...this function is in c++)

        note: this myObject is Qdeclarative element name

        my question is in this onclicked function how to send this hellow.qml to print_pdf function

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          since you already use a QDeclarativeView (derives QWidget) use it in my example. DOnt print the qml-file, instead print the view that renders the qml-file:
          @
          QPrinter printer(QPrinter::HighResolution);
          printer.setOutputFormat(QPrinter::PdfFormat);
          printer.setOutputFileName(filename);
          QPrintDialog printDialog(&printer);
          if(printDialog.exec() == QDialog::Accepted)
          {
          ui->declarativeView->render(&printer);
          }
          @

          or if you use Qt 5 you can use QPdfWriter [qt-project.org]:

          @
          QPdfWriter pdfWriter("C:/mypdf.pdf");
          ui->declarativeView->render(&pdfWriter);
          @

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0

          • Login

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