Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8463001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:20:35+00:00 2026-06-10T14:20:35+00:00

I will make this fairly quick as it’s a very simple question. How do

  • 0

I will make this fairly quick as it’s a very simple question. How do I make a slot in Qt that prints out everything inside of my text editor. Simply a print button that behaves as you’d expect a print button to behave. I’m reading about a QPrintDialog, but I can’t get it to work. This is what I tried:

QPrintDialog printDialog(printer, this);
if(printDialog.exec() == QDialog::Accepted){
    ui->textBox->print(printer);
}

I tried doing QPrinter *printer = new QPrinter before it… but that gave me all sorts of errors, which I kind of figured it would. I already have #include QPrintDialog so how do I actually get this to work? Any help or advice is much appreciated.

Edit: I was looking for an answer for my question and I found a code that seems to be closer to working if that makes sense.

QPrinter printer;

QPrintDialog *printDialog = new QPrintDialog(&printer, this);
printDialog->setWindowTitle("Print Document");
if (printDialog->exec() != QDialog::Accepted)
         return;

However, now I get an error that says:

C:\Documents and Settings\Me\My Documents\C++ Projects\Qt Gui Applications\WordWrite-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\..\WordWrite\wordwritemain.cpp:130: error: aggregate 'QPrinter printer' has incomplete type and cannot be defined
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:20:37+00:00Added an answer on June 10, 2026 at 2:20 pm

    I solved the answer to the question on the help part of the Nokia website. the code I used was:

    QPrinter printer;
    QPrintDialog *printDialog = new QPrintDialog(&printer, this);
    printDialog->setWindowTitle("Print Document");
    if (printDialog->exec() != QDialog::Accepted){
        ui->textBox->print(&printer);
    }
    

    Which is basically what I was doing before except:

    • I added &printer instead of printer

    - I added #include <QPrinter>

    Thanks for the help anyway, and I hope this helps future text editor developers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I will make this quick and simple I have a query and I want
I'm fairly new to C# but I will try to make this quick! ;)
I will make this quick. I'm using Ruby/LDAP to search using my base_dn criteria.
How do you sort an array of strings in C++ that will make this
I know that this line of code will make the cell text-wrap: $objPHPExcel->getActiveSheet()->getStyle('D1')->getAlignment()->setWrapText(true); 'D1'
Ho to make this simple xml with php using DOM? Full code will be
How can i make an extension method that will work like this public static
I'm trying to make a notification area that will show alerts. return this.each(function() {
OK, I think this will be fairly simple, but my numpy-fu is not quite
I will try to make this as clear as I can, but if you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.