PDA

View Full Version : QPrinter problem



ToddAtWSU
14th February 2008, 19:03
I am using Qt 4.3 on Solaris 9 and am having compilation problems when trying to configure a QPrinter object.


QPrinter* printer = new QPrinter( );
printer->setColorMode( QPrinter::GrayScale );

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


printer->setColorMode( QPrinter::Color );

Why does GrayScale not compile but Color does? Thanks!

jacek
14th February 2008, 23:24
Could you post the exact error message? Do you have any #define macros? What does "qDebug() << QPrinter::GrayScale;" output?

ToddAtWSU
15th February 2008, 14:34
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.



Do you have any #define macros?
No


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!

jacek
15th February 2008, 16:33
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)?


There is nothing else. Compilation dies after this point.
Is that the first error or warning you get?

ToddAtWSU
19th February 2008, 14:31
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.


Is that the first error or warning you get?
Yes, if I comment the line out, the program compiles and links successfully.

ToddAtWSU
20th February 2008, 21:20
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.