Results 1 to 6 of 6

Thread: QPrinter problem

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Red face QPrinter problem

    I am using Qt 4.3 on Solaris 9 and am having compilation problems when trying to configure a QPrinter object.

    Qt Code:
    1. QPrinter* printer = new QPrinter( );
    2. printer->setColorMode( QPrinter::GrayScale );
    To copy to clipboard, switch view to plain text mode 

    I get these compiler errors on the line setting the color mode.

    Error: Identified expected instead of "1"
    Error: Badly formed expression
    However this line compiles fine

    Qt Code:
    1. printer->setColorMode( QPrinter::Color );
    To copy to clipboard, switch view to plain text mode 

    Why does GrayScale not compile but Color does? Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPrinter problem

    Could you post the exact error message? Do you have any #define macros? What does "qDebug() << QPrinter::GrayScale;" output?

  3. #3
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Red face Re: QPrinter problem

    Quote Originally Posted by jacek View Post
    Could you post the exact error message?
    The exact error message I get when running make is
    "../src/MainWindow.cpp", Line 781: Error: Identified expected instead of "1"
    "../src/MainWindow.cpp", Line 781: Error: Badly formed expression
    There is nothing else. Compilation dies after this point.


    Quote Originally Posted by jacek View Post
    Do you have any #define macros?
    No

    Quote Originally Posted by jacek View Post
    What does "qDebug() << QPrinter::GrayScale;" output?
    I don't know. Since I cannot get the portion "QPrinter::GrayScale" to compile I don't know what it outputs when run in qDebug. I tried to run qDebug but it still wouldn't compile.

    Thanks again!

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPrinter problem

    Quote Originally Posted by ToddAtWSU View Post
    I don't know. Since I cannot get the portion "QPrinter::GrayScale" to compile I don't know what it outputs when run in qDebug. I tried to run qDebug but it still wouldn't compile.
    What does cpp -dM MainWindow.cpp | grep GrayScale outputs (you might need to pass additional options, so that cpp can find all of the headers)?

    Quote Originally Posted by ToddAtWSU View Post
    There is nothing else. Compilation dies after this point.
    Is that the first error or warning you get?

  5. #5
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPrinter problem

    Quote Originally Posted by jacek View Post
    What does cpp -dM MainWindow.cpp | grep GrayScale outputs (you might need to pass additional options, so that cpp can find all of the headers)?
    I have never seen this cpp command so I will try it out and let you know the results.

    Quote Originally Posted by jacek View Post
    Is that the first error or warning you get?
    Yes, if I comment the line out, the program compiles and links successfully.

  6. #6
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPrinter problem

    I had many problems running cpp because I needed a lot of -I arguments and unfortunately ran out of room in my command line to let me add them all in, but it still returned me 1 result with many errors. Somewhere it found a

    #define GrayScale 1

    So I know where my error is and I am thinking maybe I need to move my include files around. I had a similar problem and it was because I included an X11 file before a Qt file so maybe I will play around with the order of my includes to see if the X11 file was causing the issue.

Similar Threads

  1. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  2. QPrinter on QGraphicsScene Border Problem
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2007, 15:49
  3. QPrinter problems
    By Teuniz in forum Qt Programming
    Replies: 1
    Last Post: 3rd November 2007, 08:51
  4. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.