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. Qprinter Is there a simple Hello World example
Forum Updated to NodeBB v4.3 + New Features

Qprinter Is there a simple Hello World example

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.6k Views 2 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.
  • metron9M Offline
    metron9M Offline
    metron9
    wrote on last edited by
    #1

    Hi I just started learning QT.
    My background in programming goes back to writing assembly programs for commodore. Wrote a lot of programs using Clipper now using Flagship for compiling my old XBase code.
    I also do C programming for creating software for Atmel chips using CodeVisionAVR

    So I have finally started to migrate into the OOPS realm and i think I making some good progress however the Qprinter is really stumping me. All night trying to figure out the example fontsampler.pro in QT 5.5 using Creator 3.4.2. It's the only example I have found so far using qprinter

    I have been learning from VoidRealms videos but I have not found one on printing yet.

    In clipper I would just use this code to redirect output to the default printer:
    set print on
    @ prow(),pcol() say "hello world"
    set print off

    Of course that was when LPT ports had printers attached.

    Flagship was a bit more complicated allowing user to select printer and options like Qprinter classes but i am really stumped at the moment.

    So a little help here will go a long way.

    R 1 Reply Last reply
    0
    • metron9M metron9

      Hi I just started learning QT.
      My background in programming goes back to writing assembly programs for commodore. Wrote a lot of programs using Clipper now using Flagship for compiling my old XBase code.
      I also do C programming for creating software for Atmel chips using CodeVisionAVR

      So I have finally started to migrate into the OOPS realm and i think I making some good progress however the Qprinter is really stumping me. All night trying to figure out the example fontsampler.pro in QT 5.5 using Creator 3.4.2. It's the only example I have found so far using qprinter

      I have been learning from VoidRealms videos but I have not found one on printing yet.

      In clipper I would just use this code to redirect output to the default printer:
      set print on
      @ prow(),pcol() say "hello world"
      set print off

      Of course that was when LPT ports had printers attached.

      Flagship was a bit more complicated allowing user to select printer and options like Qprinter classes but i am really stumped at the moment.

      So a little help here will go a long way.

      R Offline
      R Offline
      Rutger7
      wrote on last edited by
      #2

      @metron9 In QtCreator click Welcom > Examples > Text Edit. This is a Qt widget main application for text editing and printing (printer and pdf). You can also play around with fonts. Good luck.

      1 Reply Last reply
      0
      • metron9M Offline
        metron9M Offline
        metron9
        wrote on last edited by
        #3

        Thanks for the information.

        I am trying to break down the textedit example. I am trying to delete one by one all of the code that is not used to print. I'm learning how and where things get connected by removing and changing lines of code along with qDebug.

        So I commented out the code in textedit.cpp
        // void TextEdit::textBold()
        //{
        // QTextCharFormat fmt;
        // fmt.setFontWeight(actionTextBold->isChecked() ? QFont::Bold : QFont::Normal);
        // mergeFormatOnWordOrSelection(fmt);
        //}

        Compiling I double click on the error
        C:\Qt\Examples\Qt-5.5\widgets\richtext\build-textedit-Desktop_Qt_5_5_0_MinGW_32bit-Debug\debug\moc_textedit.cpp:151: error: undefined reference to `TextEdit::textBold()'

        and it opens moc-textedit.cpp
        where the case 7: line calls textBold()

        Can you tell me is moc-textedit a QT generated file or where it comes from?
        Not sure why its outside the project.
        How would you go about deleting the Bold button or any other button in this code?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          moc is the Meta Object Compiler and will generate these moc files for you when you create QObject derived class that contains the Q_OBJECT macro (needed for signals and slots).

          As for your problem, textBold is a slot and thus needs an implementation so you should either comment only the code in the body of the function or also comment the function declaration in textedit.h

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          metron9M 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi and welcome to devnet,

            moc is the Meta Object Compiler and will generate these moc files for you when you create QObject derived class that contains the Q_OBJECT macro (needed for signals and slots).

            As for your problem, textBold is a slot and thus needs an implementation so you should either comment only the code in the body of the function or also comment the function declaration in textedit.h

            metron9M Offline
            metron9M Offline
            metron9
            wrote on last edited by
            #5

            @SGaist Thanks I commented out the Qaction and the function prototype and the declaration and body as well as calls to that function.

            I'm on my way now. It's kind of like taking apart a piece of hardware to see how it works, just looking at it or reading it simply does not sink in.

            I'm going to explore the debugger and how to use it tonight.

            Ill be back....

            1 Reply Last reply
            0
            • metron9M Offline
              metron9M Offline
              metron9
              wrote on last edited by metron9
              #6

              Finally it starts to sink in.
              I have put up my work in process program on Github
              I named it AsapOrderForm
              There are extra buttons I am experimenting with for saving file and other code
              I have found.

              Anyway, This program will have an input form not implemented yet and do the following.

              1. Print the form
              2. Create a PDF
              3. email the form

              Have not looked at how to implement the email part yet.

              Hope new programmers can find some of the code useful.

              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