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 6036465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:55:42+00:00 2026-05-23T05:55:42+00:00

In the imageviewer example, QPainter and QPrintDialog objects are defined and used as following:

  • 0

In the imageviewer example, QPainter and QPrintDialog objects are defined and used as following:

#ifndef QT_NO_PRINTER
QPrinter printer;
#endif

and

QPrintDialog dialog(&printer, this);

A QPainter object is then initialized with QPrinter (printer).

When I tried to use the same code in my function, it looks like:

void imageviewer::print()
{
...
#ifdef QT_NO_PRINTER

QPrinter printer(this);             //ERROR 1
QPrintDialog dialog(&printer, this);//ERROR 2 and 3

if (dialog.exec())                  //ERROR 4
{
    //do the painting
}

#endif
}

The errors are:

1. variable 'QPrinter printer' has initializer but incomplete type
2. 'QPrintDialog' was not declared in this scope
3. Expected ';' before 'dialog'
4. 'dialog' was not declared in this scope

What I am not able to understand is why are these errors arising when I am using them in my code, but not in the example.

As a friend pointed out, I made sure that I used the right #include files and made sure that ‘printer’ and ‘dialog’ were not touched anywhere else in the example.

  • 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-05-23T05:55:43+00:00Added an answer on May 23, 2026 at 5:55 am

    You are using #ifdef QT_NO_PRINTER in your code but the example uses #ifndef QT_NO_PRINTER

    Pay attention to difference between if not defined and if defined

    If your code compiles then it means that you have QT_NO_PRINTER in your project. Without a printer you can not print !

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

Sidebar

Related Questions

For example, i have this ImageViewer.ascx UserControl: <div class=ImageTumbnails> <asp:ListView ID=ImageList runat=server ItemPlaceholderID=ItemContainer> <LayoutTemplate>
Currently I have a view with an ImageViewer and 2 buttons (Browse & Upload).
The following is a dashed line, defined as a ShapeDrawable in XML: <shape xmlns:android=http://schemas.android.com/apk/res/android
I am using following example to display internet images in my activity. http://developer.android.com/resources/tutorials/views/hello-gridview.html In
I struggling with how to create my own custom dialog. I follow this example
I have used ImageView's before and understand the different scale types that can be
I am trying to create a partial view I call ImageViewer. It will be
I'm trying to have a single large UIView (for example a web view) which
I'm using the demo example in https://github.com/nicklockwood/AsyncImageView to load images asynchronously, however my app
With reference to the lunchlist example in Android PRogramming Tutorials by Mark L.Murphy, In

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.