Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9251155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:37:34+00:00 2026-06-18T10:37:34+00:00

I created QTextTable: QTextDocument *document=new QTextDocument(this); QTextCursor cursor(document); cursor.movePosition(QTextCursor::Start); QTextTableCellFormat cellFormat; cellFormat.setLeftPadding(7); cellFormat.setRightPadding(7); QBrush

  • 0

I created QTextTable:

QTextDocument *document=new QTextDocument(this);
QTextCursor cursor(document);
cursor.movePosition(QTextCursor::Start);

QTextTableCellFormat cellFormat;
cellFormat.setLeftPadding(7);
cellFormat.setRightPadding(7);

QBrush blackBrush(Qt::SolidPattern);
QTextTableFormat tableFormat;
tableFormat.setAlignment(Qt::AlignCenter);
tableFormat.setBorderBrush(blackBrush);
tableFormat.setBorder(0.5);
tableFormat.setCellSpacing(0);
tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
tableFormat.setWidth(QTextLength(QTextLength::PercentageLength, 100));
QTextTable *table = cursor.insertTable(10,10,tableFormat);

QTextBlockFormat centerAlignment;
centerAlignment.setAlignment(Qt::AlignCenter);

table->mergeCells(0,0,10,5);
cursor = table->cellAt(0, 0).firstCursorPosition();
cursor.setBlockFormat(centerAlignment);
cursor.insertText("text");

I want to write text in the middle of cell vertically and horizontally
But my text is in the middle horizontally but it is not in the middle vertically.
Also Qt::AlignVCenter and Qt::AlignBottom do not work.
I tried this answer https://stackoverflow.com/a/10329809/1997790 but it is not worked.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:37:35+00:00Added an answer on June 18, 2026 at 10:37 am

    You might try using QTextCharFormat::setVerticalAlignment(), as in:

    QTextTableCell   cell = table->cellAt(0, 0);
    QTextCharFormat  cellFormat = cell.format();
    
    cellFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
    cell.setFormat(cellFormat);
    

    If that doesn’t work, you might want to try using style sheets to customize the table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Created a new App, created a new Fanpage for this App but if i
I created a new product type and everything works except the indexing of the
Created new scaffold Users that has fields name & description All working as suppose
Created a new project from the Tab Bar Application template, how can I access
created a new IIS7 web site with Intergrated .net 4.0 app pool. URLs ending
I created a constraint on my tsql table like this: alter table disabledqualities add
Created a new Android project. Added the library (https://github.com/johannilsson/android-actionbar) for instructions http://www.jetbrains.com/idea/webhelp/sharing-android-source-code-and-resources-using-library-projects.html . In
I created a new MVC 4 web project (VS 2012 Express) and installed the
I created a HTML page with a number of tables with headers like this:
I created this form in VS The NumPlace TextBox is intalized to 1 automatically,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.