Results 1 to 6 of 6

Thread: QPageSetupDialog problem

  1. #1

    Default QPageSetupDialog problem

    I used qt 4.2.2 on windows.

    Qt Code:
    1. QPrinter printer;
    2. printer.setResolution(QPrinter::HighResolution);
    3. QPageSetupDialog psd(&printer);
    4. if(psd.exec() != QDialog::Accepted)
    5. return;
    6. ......
    To copy to clipboard, switch view to plain text mode 

    QPageSetupDialog will show native page setup dialog.
    I can set margins in this dialog, however, it will not tak any effect.
    When reopen the dialog, the margin will be the default values.
    I tried to manually to set QPrinter's page rectangle via
    printer.printEngine->setProperty(QPrintEngine::PPK_PageRect,...).
    But it does not work either.

    I don't know there's any way to set the margin in page setup dialog.
    Thanks!
    Last edited by jpn; 15th March 2008 at 08:33. Reason: missing [code] tags

  2. #2

    Default Re: QPageSetupDialog problem

    help me please!

  3. #3
    Join Date
    Jan 2006
    Location
    Hannover, Germany
    Posts
    14
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPageSetupDialog problem

    You create a new QPrinter object on the stack every time you enter your function. So every change you make will be deleted together with your QPrinter object at the end of your function. Try to create a member variable of QPrinter on the heap. This will allow you to save your changes.

    HTH,
    Weilor

  4. #4

    Default Re: QPageSetupDialog problem

    Oh, actually the QPrinter object is a member variable in my code. It seems that you did not have a try. It will remember all the settings except margins. I found the same problem on the demo example of qt.
    $(QTDIR)\demos\textedit.
    Is this a bug for Qt?

    Thanks all the same!

  5. #5
    Join Date
    Jan 2006
    Location
    Hannover, Germany
    Posts
    14
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPageSetupDialog problem

    Well, in the code you posted here printer is not a member variable, so I thought that there might be the problem.
    Anyway, I tested the textedit demo with Qt4.2.2 on windows and I did not run into the problem you mentioned. The QPageSetupDialog remembers all settings, even the margins. If this problem occurs even in the demo you should check your Qt installation or upgrade to a newer version or contact Trolltech.

    Greets,
    Weilor

  6. #6

    Default Re: QPageSetupDialog problem

    It is a so strange problem, I tested this on other colleagues' machines and it did appear. My qt's version is commercial 4.2.2. I tried to follow up the source code. QPrinter does not provide any API for setting margins! But I find such API in 4.4 beta1.
    Weilor, would you mind sending me the demo textedit's binary?
    My mail is mendynew@163.com
    Thanks very much!

Similar Threads

  1. problem with opengl, zooming, drawpixels, and origin
    By ntp in forum General Programming
    Replies: 0
    Last Post: 22nd February 2008, 21:48
  2. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  3. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  4. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14: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.