
下面只是给出一段演示代码,你需要根据实际情况进行修改
QTextEdit editer;
editersetText("abcdef");
QTextCursor cursor = editertextCursor();
//将光标移动到文本结尾,便于删除字符测试,实际上并不需要该步骤
cursormovePosition(QTextCursor::End);
//判断当前是否选中了文本,如果选中了文本则取消选中的文本,再删除前一个字符
if(cursorhasSelection())
cursorclearSelection();
//删除前一个字符
cursordeletePreviousChar();
//设置当前的光标为更改后的光标
editersetTextCursor(cursor);
editershow();
你可以调用subprocess的方法,获取stdout,然后将其append到textedit中;
你也可以将你的外部程序输出到文本,然后读取文件,将读取的结果放到textedit。
resize()函数是有用的
QTextEdit textEdit;
textEditresize(100,22);
QHBoxLayout layout = new QHBoxLayout;
layout->addWidget(&textEdit);
最后不要忘了在某处调用setLayout();这个函数,需要视布局而定
QLINEEDIT 类里的方法
int cursorPosition() const;
void setSelection(int, int);
QString selectedText() const;
找到想取出的字符串,设置选中,再用selectedText取出,
或者可以研究一下QTextCursor
QTextCursor cursor(ui->textEdit->textCursor());//
可以获取光标位置,移动光标等等
在一个应用程序上工作,我有选项卡名称的问题。 当我点击按钮(新)时,我想动态创建新标签。
使用此功能,我创建新文件:
bool MainWindow::toolbarNewFile()
{
QWidget page = new QWidget;
QTextEdit codeEditor = new QTextEdit;
QGridLayout layout = new QGridLayout;
layout->addWidget(codeEditor);
page->setLayout(layout);
tab_widget->addTab(page,"File");
return true;
}
但所有标签都有名称“FILE”
如何在标签名称编号中设置。 当我制作新选项卡时,自动设置选项卡的编号如下。
文件-1,文件-2,文件-3
我试着设置counter i=0; 并在addTab(page,"File-"+ i++); 不起作用。
I working on one application and I have problem with tab name When I click on push button (NEW) I want to dynamically create new tab
With this function i create new file:
bool MainWindow::toolbarNewFile()
{
QWidget page = new QWidget;
QTextEdit codeEditor = new QTextEdit;
QGridLayout layout = new QGridLayout;
layout->addWidget(codeEditor);
page->setLayout(layout);
tab_widget->addTab(page,"File");
return true;
}
But all tabs have name "FILE"
How to set in tab name number When i make new tab auto set number of the tab like this
File-1, File-2, File-3
I try to set counter i=0; and in addTab(page,"File-"+ i++); Doesn't work
原文:>
以上就是关于qt qtextedit 怎样删除光标前一个字符全部的内容,包括:qt qtextedit 怎样删除光标前一个字符、Python如何调用外部程序,使外部程序的输出显示在Qtextedit啊啊啊!!!、QT中怎么设置QTextEdit和QHBoxLayout初始大小呢等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)