qt - Problems between C++ and qml -


I am creating an app using Qt Quick Control and I need some C ++ in it (to print and read the file)

. I've lost it, so I've modified it for your needs:

Boney H

  #ifndef BONURI_H #define BONURI_H # Include & lt; QObject & gt; # Include & lt; QTemporaryFile & gt; # Include & lt; QIODevice & gt; # Include & lt; QPainter & gt; # Include & lt; QtSvg / QSvgRenderer & gt; # Include & lt; QFile & gt; # Include & lt; QTextStream & gt; # Include & lt; QtPrintSupport / QPrintPreviewDialog & gt; # Include & lt; QtPrintSupport / QPrinter & gt; Class Bonuri: Public QObject {Q_OBJECT Public: Clear Bonuri (QObject * Parents = 0); Public Slots: Zero Print SVG (Constructing and In); Caststring list (); Zero real print (QPrinter * p, const QString & amp; in;); }; #exif // BONURI_H  

bonuri.cpp

  #include "bonuri.h" Bonuri :: Bonuri (QObject * Parents): QObject (parent) {} zero Bonuri :: printSVG (in const QString & amp;) {QPrinter printer (QPrinter :: HighResolution); Printer.setPaperSize (QPrinter :: A5); QPrintPreviewDialog printhead (and printers); Connect (& Print Dialog, Signal (paint requested (QPrinter *)), slot (actual print (QPrinter *, in))); PrintDialog.exec (); } Actual actual print (QPrinter * p, const QString & amp; in) {QTemporaryFile file; If (file.open ()) {queststream out (& file); Outside & lt; & Lt; In; QSvg Render Renderer (file.fileName ()); Cooperator MyPainter (P); MyPainter.setRenderHints (QPainter :: Antialiasing | QPainter :: TextAntialiasing | QPainter :: SmoothPixmapTransform); Renderer.render (& myPainter); }} Caststring list () {QFile file ("Bonuri.json"); Qustring total lean; If (file.open (QIODevice :: ReadOnly | QIODevice :: Text)) {(and file) in QTextStream; While (! In.atEnd ()) {QString line = in.readLine (); TotalLine + = Row; }} Returned; }  

The problem is that I am not a big C ++ expert and it was not able to debug it.

Problem: moc_bonuri CPP

Undefined context for 'BONARY :: list ()'; One more thing: can you help me optimize the code (I am new to C ++ and in fact it is not known why it is the way it is, I have just used the example.) < / P>

should be:

  void Bonuri :: actualPrint (QPrinter * p , Const in QString & amp;) {// QTemporaryFile file; // Now if it is a class member (file.open ()) {QTextStream out (& amp;; file); Outside & lt; & Lt; In; QSvg Render Renderer (file.fileName ()); Cooperator MyPainter (P); MyPainter.setRenderHints (QPainter :: Antialiasing | QPainter :: TextAntialiasing | QPainter :: SmoothPixmapTransform); Renderer.render (& myPainter); }} QString Bonuri :: list () {QFile file ("Bonuri.json"); Qustring total lean; If (file.open (QIODevice :: ReadOnly | QIODevice :: Text)) {(and file) in QTextStream; While (! In.atEnd ()) {QString line = in.readLine (); TotalLine + = Row; }} Returned; } Another problem:  
  connect (& print dialog, signal (paint requested), slot (actual print (QP printer) *, In)) );  

You can not use more logic than the signal, you can not use less, but no more. Therefore it should be at least:

  connect (and printed, signal (paint requested), slot (actual printer (* *));  

But in this case you should completely rewrite your method.

  class Bonuri: public QObject {Q_OBJECT Private: QTemporaryFile file; // ...  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -