首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >QTextCursor、QTextTable和默认左边框

QTextCursor、QTextTable和默认左边框
EN

Stack Overflow用户
提问于 2015-07-30 13:11:04
回答 1查看 640关注 0票数 0

我被生成了一个qtextdocument来打印它。在我的文档中插入一个QTextTable。

我的问题是,默认情况下,该表有一个左边距,并且我找不到如何删除它。

结果实例:

代码语言:javascript
复制
Some text
     table row 1
     table row 2

我需要的结果是:

代码语言:javascript
复制
Some text
table row 1
table row 2

我的代码:

代码语言:javascript
复制
QTextDocument textDocument;
QTextCursor cursor(&textDocument);


cursor.insertText("Some text");

QTextTableFormat tableFormat;
tableFormat.setCellPadding(5);
tableFormat.setHeaderRowCount(2);
tableFormat.setAlignment(Qt::AlignCenter);
tableFormat.setTopMargin(10);
tableFormat.setPadding(0);
tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
tableFormat.setBorderBrush(QBrush(Qt::black, Qt::SolidPattern));
tableFormat.setWidth(QTextLength(QTextLength::PercentageLength, 100));
tableFormat.setCellSpacing(0);
tableFormat.setLeftMargin(0);
QTextTable *table = cursor.insertTable(2, 11, tableFormat);

如果你能帮我,谢谢;)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-30 15:58:25

这一行需要更改:

代码语言:javascript
复制
tableFormat.setAlignment(Qt::AlignCenter);

代码语言:javascript
复制
tableFormat.setAlignment(Qt::AlignLeft);

或者干脆把setAlignment完全排除在外。

该表的宽度需要设置为它所在容器的100%。

希望这能有所帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31724772

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档