QPrinterDialog don't give the good paper size



  • hello everybody,

    I have a big problem ;)!!Yan can maybe help me.

    I have two printer
    -BROTHER 21cm29.7cm
    -Dymo(sticker printer) :3,2cm
    5,7cm

    when i call QPrintDialog and select the printer I want.The printer nam of the current printer changed but not the pageRect ,pageSize...and continue to give me the size of default printer.

    Exemple

    @void MainWindow::openprinterconfig()
    {

       QPrintDialog *dialog = new QPrintDialog(myprinter);
    
       dialog->exec() ;
       qDebug("%f", myprinter->paperRect(QPrinter::Millimeter).height());
       qDebug("%f", myprinter->paperRect(QPrinter::Millimeter).width());
       qDebug(myprinter->printerName().toLocal8Bit());
    

    }@

    case 1:Dymo is default printer and i try to select BROTHER printer
    31.750000
    57.150000
    Brother HL-2140

    case 2:BROTHER is default printer and i try to select Dymo printer
    297.000000
    210.000000
    DYMO LabelWriter 450

    If i try to print the selected printer in Qdialog work but I have to get the papersize in my application.

    Couold you help me Please?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Pretty strange indeed. What version of Qt/OS are you running ? What compiler are you using ?



  • I use qt on Windows 7 64 bits with QT Crator 3.2.0 and QT 5.3.1
    I use the compiler mingw 4.82



  • and thanks for your answers



  • Hi, just guessing but try calling myprinter->setFullPage(true); just before the paperRect() calls.



  • Unfortunately the problem continue,

    with this code
    QPrintDialog *dialog = new QPrintDialog(this);
    @ if(dialog->exec() ==QDialog::Accepted)

       {
            QPrinter* printer3 = dialog->printer()  ;
            qDebug(dialog->printer()->printerName().toLocal8Bit());
            printer3->setFullPage(true);
            qDebug("%f", printer3->pageRect(QPrinter::Millimeter).height());
            qDebug("%f", printer3->pageRect(QPrinter::Millimeter).width());
        }@
    

    QT return:

    if the BROTHER is the default printer:
    DYMO LabelWriter 450
    297.000000
    210.000000

    if the DYMO is the default printer:
    DYMO LabelWriter 450
    31.750000
    57.150000


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.