Results 1 to 2 of 2

Thread: Sync Width

  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Sync Width

    How to synchronize QTextEdit width with QPrinter Paper width, and QTextEdit document margin with QPrinter page margin.

    I not have a good method

    Width like sync with this code. But I'm not sure.
    Qt Code:
    1. //sync width
    2. int mw=printer.paperSize(QPrinter::DevicePixel).width();
    3. ui->textEdit->setMaximumWidth(mw);
    To copy to clipboard, switch view to plain text mode 


    And code for sync margin still not work
    Qt Code:
    1. //sync margin
    2. printer.setPageMargins(20, 20, 20, 20, QPrinter::DevicePixel);
    3. ui->textEdit->document()->setDocumentMargin(20);
    4.  
    5.  
    6. //I use GIMP and get 1pixel is 0.35 millimeter
    7. qreal aa=0.35 * 20.0;
    8. printer.setPageMargins(aa, aa, aa, aa, QPrinter::Millimeter);
    9. ui->textEdit->document()->setDocumentMargin(20);
    To copy to clipboard, switch view to plain text mode 


    Sorry, with my english..

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Sync Width

    What do you mean by "sync"? The text edit is completely irrelevant. What is important is the text document it operates on. "Synchronize" the widget with the document and then print the document on the printer setup properly for the document size.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to set QTableView width to width of horizontal header?
    By martinb0820 in forum Qt Programming
    Replies: 0
    Last Post: 2nd December 2008, 20:51
  2. Replies: 4
    Last Post: 15th October 2008, 13:24
  3. Scaling of pen width in QGraphicsView
    By spuds in forum Qt Programming
    Replies: 3
    Last Post: 30th May 2008, 01:47
  4. QTableWidget column width and resizing
    By shooogun in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2008, 22:31
  5. How to obtain the width of a QTableWidget?
    By Giel Peters in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2006, 22:34

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.