Results 1 to 7 of 7

Thread: Qt3 to Qt4 printer setup confusion

  1. #1
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Qt3 to Qt4 printer setup confusion

    In QT3 the code
    Qt Code:
    1. QPrinter myprinter; // = new QPrinter();
    2. myprinter.setPageSize( QPrinter::Letter );
    3. myprinter.setOrientation( QPrinter::Portrait );
    4. myprinter.setColorMode( QPrinter::Color );
    5. myprinter.setFullPage ( true );
    6. ret = myprinter.setup();
    7. if( ret == true )
    8. {
    9. QPainter p( &myprinter );
    To copy to clipboard, switch view to plain text mode 
    gave the user of a program the oppurtunity to change the default perameters for a print out. Qt4 says to use "QPrintDialog printDialog" for this.
    The "Detailed Description" for this function says
    Typically, QPrintDialog objects are constructed with a QPrinter object, and executed using the exec() function.

    QPrintDialog printDialog(printer, parent);
    if (printDialog.exec() == QDialog::Accepted) {
    // print ...
    }
    I am a bit of a newbie in deciphering Qt4's style of documentation and with no print examples that I can find I need help.

    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: Qt3 to Qt4 printer setup confusion

    Quote Originally Posted by impeteperry
    QPrintDialog printDialog(printer, parent);
    if (printDialog.exec() == QDialog::Accepted) {
    // print ...
    }
    It's a Qt4 equivalent of:
    Qt Code:
    1. ret = myprinter.setup();
    2. if( ret == true )
    3. {
    4. // print ...
    5. }
    To copy to clipboard, switch view to plain text mode 
    The "print ..." part didn't change much in Qt4, i.e. it's something like this:
    Qt Code:
    1. p.begin( &myprinter );
    2. p.setPen( ... );
    3. p.drawLine( 10, 10, 100, 100 );
    4. ...
    5. p.end();
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt3 to Qt4 printer setup confusion

    Thanks, actually I am able to print ok in Qt4, but what I wanted is to display a window similar to the one i get with
    ret = myprinter.setup();
    in Qt3.

  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: Qt3 to Qt4 printer setup confusion

    Quote Originally Posted by impeteperry
    what I wanted is to display a window similar to the one i get with ret = myprinter.setup(); in Qt3.
    Then try QPageSetupDialog.

  5. #5
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt3 to Qt4 printer setup confusion

    Thanks. I am new to this and am is the learning process and am totally confused.. I would appreciate it if, using the code snippit in my original post, you wold show the code to do what the
    ret = myprinter.setup();
    did in Qt3.

    Thanks

    pete

  6. #6
    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: Qt3 to Qt4 printer setup confusion

    Quote Originally Posted by impeteperry
    I am new to this and am is the learning process and am totally confused.. I would appreciate it if, using the code snippit in my original post, you wold show the code to do what the did in Qt3.
    It's something like:
    Qt Code:
    1. #include <QPageSetupDialog>
    2. ...
    3. QPrinter myprinter;
    4. myprinter.setPageSize( QPrinter::Letter );
    5. myprinter.setOrientation( QPrinter::Portrait );
    6. myprinter.setColorMode( QPrinter::Color );
    7. myprinter.setFullPage ( true );
    8.  
    9. QPageSetupDialog dialog( &myprinter, this );
    10. if( dialog.exec() == QDialog::Accepted ) {
    11. ...
    12. }
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to jacek for this useful post:

    impeteperry (5th May 2006)

  8. #7
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt3 to Qt4 printer setup confusion

    Thanks a whole lot. You gave me the clue I was lookng for. I forgot the "#include"
    What I had was
    Qt Code:
    1. QPrintDialog dialog(&myprinter, this);
    2. if (dialog.exec() == QDialog::Accepted)
    To copy to clipboard, switch view to plain text mode 
    but not the #Include.
    This gives me the "dialog" I was looing for.

    Life is simple when you know what you are doing. Now I can go away happy.

    Thanks again.
    Last edited by impeteperry; 5th May 2006 at 12:51.

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.