首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >创建QTextTable和插入数据

创建QTextTable和插入数据
EN

Stack Overflow用户
提问于 2015-03-12 15:07:41
回答 1查看 2.4K关注 0票数 0

我正在尝试创建一个QTextTable并将数据插入其中。目前,由于几个错误,我无法创建该表。

未声明标识符“编辑器”的使用

我也不确定如何将数据插入到TextTable中。我的代码在下面

代码语言:javascript
复制
QTextCursor cursor(editor->textCursor());
cursor.movePosition(QTextCursor::Start);
QTextTable *table = cursor.insertTable(5, 3);

我尝试了下面的代码,没有错误,我只是想知道如何将数据插入到文本中以便打印出来?

代码语言:javascript
复制
QTextEdit *editor = new QTextEdit();
QTextCursor cursor(editor->textCursor());
cursor.movePosition(QTextCursor::Start);
QTextTable *table = cursor.insertTable(5, 3);
table->insertRows(0, 5);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-12 15:19:18

添加文本浏览器并尝试此浏览器。(表单包含一个对象名为QTextBrowsertextBrowser)

代码语言:javascript
复制
QTextCursor cursor(ui->textBrowser->textCursor());
cursor.movePosition(QTextCursor::Start);

QTextTable *table = cursor.insertTable(2, 3);

for(int i=0; i<2; i++)
{
    for(int j=0; j<3; j++)
    {

        table->cellAt(i, j).firstCursorPosition().insertText("Hello");
    }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29013381

复制
相关文章

相似问题

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