[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] [PYQT]How to set my text data in qtextedit as html
From:       Maziar Parsijani <maziar.parsijani () gmail ! com>
Date:       2018-09-24 14:32:46
Message-ID: CAPD04aP9k1KJO3yvhO5rVfxY0k7g7xUnSe9fk5cmuwAucEY7mg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,
I have a data in sqlte db now i want to retrieve my data and set it in
qtextedit.

> self.SearchResults = QtWidgets.QTextEdit(self)
>
> cur = conn.cursor()
> conn.text_factory = str
> qury = sth
> cur.execute(qury)
> self.all_rows = cur.fetchall()
>
> for row in self.all_rows:
>
> self.SearchResults.append('{0} )-A={2}'.format(b, row[0]))
>
> Now how could I add the rows as html code.LIKE BELOW?

> "<html><head><meta name=\"qrichtext\" content=\"1\" /><style
> type=\"text/css\">\n"
> "p, li { white-space: pre-wrap; }\n"
> "</style></head><body style=\" font-family:\'Amiri\'; font-size:9pt;
> font-weight:400; font-style:normal;\">\n"
> "<p align=\"right\" style=\" margin-top:0px; margin-bottom:0px;
> margin-left:0px; margin-right:0px; -qt-block-indent:0;
> text-indent:0px;\"><span style=\"
> font-family:\'Sans\';\">TEXT</span></p></body></html>"
>

[Attachment #5 (text/html)]

<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><div>Hi,<br></div>I have a data in sqlte db now i want to retrieve my data and set it \
in qtextedit.<br><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><pre \
style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;DejaVu Sans \
Mono&quot;;font-size:9.1pt"><span style="color:rgb(148,85,141)">self</span>.SearchResults = \
QtWidgets.QTextEdit(<span style="color:rgb(148,85,141)">self</span>) \
<br></pre></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><pre \
style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;DejaVu Sans \
Mono&quot;;font-size:9.1pt">cur = conn.cursor()<br>conn.text_factory = <span \
style="color:rgb(0,0,128)">str<br></span>qury = <span \
style="color:rgb(0,128,128);font-weight:bold">sth</span><br>cur.execute(qury)<br><span \
style="color:rgb(148,85,141)">self</span>.all_rows = cur.fetchall()<span \
style="color:rgb(0,0,128);font-weight:bold"></span><span \
style="color:rgb(0,0,128);font-weight:bold"></span></pre></blockquote><div></div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><pre \
style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;DejaVu Sans \
Mono&quot;;font-size:9.1pt"><span style="color:rgb(0,0,128);font-weight:bold">for </span>row \
<span style="color:rgb(0,0,128);font-weight:bold">in </span><span \
style="color:rgb(148,85,141)">self</span>.all_rows:</pre></blockquote><div></div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><pre \
style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;DejaVu Sans \
Mono&quot;;font-size:9.1pt"><span style="color:rgb(148,85,141)"></span><span \
style="color:rgb(148,85,141)">self</span>.SearchResults.append(<span \
style="color:rgb(0,128,128);font-weight:bold">&#39;{0} )-</span><span \
style="color:rgb(0,128,128);font-weight:bold">A={2}</span><span \
style="color:rgb(0,128,128);font-weight:bold">&#39;</span>.format(b, row[<span \
style="color:rgb(0,0,255)">0</span>]))</pre></blockquote><div>Now how could I add the rows as \
html code.LIKE BELOW?<br><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">&quot;&lt;html&gt;&lt;head&gt;&lt;meta \
name=\&quot;qrichtext\&quot; content=\&quot;1\&quot; /&gt;&lt;style \
type=\&quot;text/css\&quot;&gt;\n&quot;<br>&quot;p, li { white-space: pre-wrap; \
}\n&quot;<br>&quot;&lt;/style&gt;&lt;/head&gt;&lt;body style=\&quot; \
font-family:\&#39;Amiri\&#39;; font-size:9pt; font-weight:400; \
font-style:normal;\&quot;&gt;\n&quot;<br>&quot;&lt;p align=\&quot;right\&quot; style=\&quot; \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px;\&quot;&gt;&lt;span style=\&quot; \
font-family:\&#39;Sans\&#39;;\&quot;&gt;TEXT&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&quot;<br></blockquote><div> \
</div></div><div>  </div><div>  </div></div></div></div></div></div></div>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic