Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPrinter ignores QTextBlockFormat Qt::AlignmentFlag

QPrinter ignores QTextBlockFormat Qt::AlignmentFlag

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 739 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vaquita Tim
    wrote on last edited by
    #1

    I have a problem when printing my QTextDocument :- parts that are horizontally centered, which appear as expected on screen, always appear aligned to the left margin when printed.

    Here's what I'm doing :-
    @
    QTextBlockFormat TitleBlockFormat;
    TitleBlockFormat.setIndent( Indent );
    TitleBlockFormat.setTopMargin( m_DisplayOptions.m_ParagraphTopMargin );
    TitleBlockFormat.setAlignment ( (Qt::Alignment) m_DisplayOptions.m_TitleAlignment );
    a_TextCursor.setBlockFormat( TitleBlockFormat );
    @
    @
    QPrinter printer;
    QPrintDialog *dlg = new QPrintDialog(&printer, this);
    dlg->setOption( QAbstractPrintDialog::PrintSelection, ui.MainContentTextEdit->textCursor().hasSelection() );
    if (dlg->exec() != QDialog::Accepted)
    return;
    ui.MainContentTextEdit->print( &printer );
    @

    Hmm - maybe I should sort out that c-style cast, but you can trust me that the m_TitleAlignment is the right value, given that it works nicely on-screen.

    To me it looks like a QPrinter bug, but I can't see any references to this problem out in the webosphere, so I'm guessing it's me.

    Do other people do aligment in some other way that works when printing ? or that maybe there's some trick I should apply to the printer for some reason to turn alignment on ?

    -Maybe it's related to paragraphs ?! You can have multiple text blocks in one paragraph, can't you...?! Maybe I've got another block on the end which has a left aligned flag...-
    I checked - I only have the one text block per paragraph as far as I can tell.

    If you have any clues, chip in...

    Qt 5.2; VS2013; Win8

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved