Printing problem in windows
Hi,
I am proting my application from qt3 to qt4 using Qt3Support.
My Problem is , in my PRINTING CODE ( which was working both in WINDOWS && LINUX in Qt3 ) . Now after porting to Qt4 the same PRINTING CODE is CRASHING in WINDOWS...
See the code below ....
Code:
void ChemCanvas::printToPrinter( const RouteList *routeList )
{
// printer object
#if (QT_VERSION < 0x030000)
#else
#endif
// original wcOrigin, saved to be restored after printing.
QPoint originalWcOrigin
= wcOrigin;
// With this set as true, objectNeedsRepainting won't
// draw while scaling to printer canvas
printing = TRUE;
// Set default printer characteristics to conform to the current
// canvas settings.
printer.setPageSize ( mappings.pageSize() );
printer.setOrientation( mappings.orientation() );
printer.setOutputFileName (
(const char *)chemGlobals->printerDefaultFilename() );
qDebug() << (const char *)chemGlobals->printerDefaultFilename();
// printer.setOutputToFile ( FALSE );
// Set full page mode, in order to have control of page size
printer.setFullPage( TRUE );
// Run the printer setup dialog, and if the user clicks 'ok' then
// do the actual printing
#if defined(_OS_WIN32_) || defined(Q_OS_WIN32)
Q_CHECK_PTR(&printer);
//if ( printer.setup( this ) )
Q_ASSERT( printDialog );
if( printDialog
->exec
() == QDialog::Accepted ) // HERE IT IS CRASHING... #else
printerDialog.setPrinter( &printer, TRUE );
if( printerDialog.exec() )
#endif
{
// Set the hourglass cursor
------------------
------------------ // Other stuff for printing...
-------------------
}
}
Please tell me why it is CRASHING only in WINDOWS .
Its working in LINUX properly.
Hlep me ...!!!
thanks in advance..
Re: Printing problem in windows
WHY NOOOOO ...REPLY..???
IS there anybody to help me or to give a hint...????
Re: Printing problem in windows
Could you run it in debugger and paste the backtrace?
Re: Printing problem in windows
Ok, I got know there is a problem
in this code
Code:
printer.setOutputToFile ( FALSE );
Once commented, the control goes to this
Code:
if ( printer.setup( this ) )
Finally to this function..
Code:
{
return qt_compat_QPrinter_printSetup(this, d, parent)
#ifdef Q_WS_MAC
&& qt_compat_QPrinter_pageSetup(this, parent);
#endif
;
}
The application crashes. Any idea :confused:
Ok one more thing, I get this warning QPrintDialog, Only native format supported. What to do???
-->Edit-->
Ok I have changed the code from
Code:
if (printer->setup(parent))
...
you can rewrite it as
if (dialog.exec())
Still there is crashing, I still get QPrintDialog, Only native format supported,
In int QPrintDialog::exec() function "ep" which is "QWin32PrintEnginePrivate *ep;" is 0. Any idea???
Re: Printing problem in windows
Quote:
Originally Posted by
joseph
Ok, I got know there is a problem
in this code
Code:
printer.setOutputToFile ( FALSE );
Once commented, the control goes to this
Code:
if ( printer.setup( this ) )
Finally to this function..
Code:
{
return qt_compat_QPrinter_printSetup(this, d, parent)
#ifdef Q_WS_MAC
&& qt_compat_QPrinter_pageSetup(this, parent);
#endif
;
}
The application crashes. Any idea :confused:
Ok one more thing, I get this warning
QPrintDialog, Only native format supported. What to do???
-->Edit-->
Ok I have changed the code from
Code:
if (printer->setup(parent))
...
you can rewrite it as
if (dialog.exec())
Still there is crashing, I still get
QPrintDialog, Only native format supported,
In
int QPrintDialog::exec() function "ep" which is "QWin32PrintEnginePrivate *ep;" is 0. Any idea???
Ok, got it... I need to do this
printer.setOutputFormat ( QPrinter::NativeFormat );
and works fine.
Is it correct????
Re: Printing problem in windows
Just curious, what's the file name?
QPrinter::setOutputFileName():
Quote:
This can change the value of outputFormat(). If the file name has the suffix ".ps" then PostScript is automatically selected as output format. If the file name has the ".pdf" suffix PDF is generated. QPrinter will use Qt's cross-platform PostScript or PDF print engines respectively. If you can produce this format natively, for example Mac OS X can generate PDF's from its print engine, set the output format back to NativeFormat.
Re: Printing problem in windows
Quote:
Originally Posted by
jpn
Aaha, That was the problem... the filename is "file.ps" so accroding to comments, fileFormat is taken as PDF.
Thanks a lot.