我有功能,只返回选定的文本从qtextedit。 我需要获取纯文本,但此函数返回带有一些控制字符的文本。qtextedit selectedtext()返回控制字符
例如: 功能textEdit->的TextCursor()selectedText()的返回:
"select? timestamp,? strftime('%d.%m.%Y', Datetime(timestamp, 'unixepoch', 'localtime')) as date,? strftime('%H:%M:%S', Datetime(timestamp, 'unixepoch', 'localtime')) as time,? author,? from_dispname,? dialog_partner,? body_xml?from? Messages?where? timestamp >= 1501504199? -- timestamp >= 1502345001?order by? timestamp asc"
功能textEdit-> toPlainText()的返回:
"select\n timestamp,\n strftime('%d.%m.%Y', Datetime(timestamp, 'unixepoch', 'localtime')) as date,\n strftime('%H:%M:%S', Datetime(timestamp, 'unixepoch', 'localtime')) as time,\n author,\n from_dispname,\n dialog_partner,\n body_xml\nfrom\n Messages\nwhere\n timestamp >= 1501504199\n -- timestamp >= 1502345001\norder by\n timestamp asc"
在第一示例中是(问号)没有进入,我无法取代他们。
我在做什么错?
另外: 第二个例子效果很好。第一个在sqlite中是不可用的,因为有问号 – exo
这很可能是QTextCursor的限制。为什么不使用第二个例子?换行符在sqlite中很好 – Felix
因为我只需要选定的文本。第二个例子返回所有文本。在例子中都是相同的(对于ilustration)...但是在实际情况下,我将只需要几条来自所有的选定行。 – exo