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

List:       pykde
Subject:    Re: [PyQt] [PYQT]Search in QTextedit
From:       Maziar Parsijani <maziar.parsijani () gmail ! com>
Date:       2018-08-19 17:16:00
Message-ID: CAPD04aMMjMXbFjpMScgy98AonX=tM+y+jYoQ3HBUrNN5u1oyEA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Florian
I used This

self.SearchResults.find(self.lineEdit.text(),QTextDocument.FindBackward)

But as I said I have to find all items one by one.I want to find them
all at once.


On Sun, Aug 19, 2018 at 8:58 PM, Maziar Parsijani <
maziar.parsijani@gmail.com> wrote:

> For more Info I have to say that I first find what I want with below code in \
> sqlite.after that I use the other code with regix to highlight results. 
> and another reason is that its gonna be faster.And I can not count results in \
> sqlite if there are more that on results in a row. 
> 
> with conn:
> cur = conn.cursor()
> conn.text_factory = str
> 
> qury = (" SELECT * FROM Translation WHERE table LIKE \
> '%{0}%';").format(self.lineEdit.text()) cur.execute(qury)
> self.all_rows = cur.fetchall()
> a = 1
> for row in self.all_rows:
> self.SearchResults.append('{0} )- {1} ﴿ {2}:mjp ={3} ﴾'.format(a, row[4], \
> row[2], row[1])) self.SearchResults.append('{0} '.format((row[3])))
> self.SearchResults.append("")
> a = a + 1
> 
> 
> On Sun, Aug 19, 2018 at 8:49 PM, Maziar Parsijani <
> maziar.parsijani@gmail.com> wrote:
> 
> > Yes thats not help full because it is important for me to foreground the
> > results all together. For example: "Hello world"is my text when I want to
> > search "l"I want it to be highlighted .I couldn't do that with
> > QTextEdit::find.
> > 
> > On Sun, Aug 19, 2018 at 8:34 PM, Florian Bruhin <me@the-compiler.org>
> > wrote:
> > 
> > > On Sun, Aug 19, 2018 at 08:31:13PM +0430, Maziar Parsijani wrote:
> > > > I use the below code to search in qtextedit to match a word.Are there
> > > any
> > > > better Idea.
> > > 
> > > Are you aware that there's a QTextEdit::find method?
> > > 
> > > Florian
> > > 
> > > --
> > > https://www.qutebrowser.org | me@the-compiler.org (Mail/XMPP)
> > > GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
> > > I love long mails! | https://email.is-not-s.ms/
> > > 
> > 
> > 
> 


[Attachment #5 (text/html)]

<div dir="ltr"><div>Florian<br></div><div>I used This <br><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.find(<span \
style="color:rgb(148,85,141)">self</span>.lineEdit.text(),QTextDocument.FindBackward)<br></pre><pre \
style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;DejaVu \
Sans Mono&quot;;font-size:9.1pt">But as I said I have to find all items one by one.I \
want to find them all at once. <br></pre></div></div><div \
class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 19, 2018 at 8:58 PM, \
Maziar Parsijani <span dir="ltr">&lt;<a href="mailto:maziar.parsijani@gmail.com" \
target="_blank">maziar.parsijani@gmail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr"><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 more Info I have to say that I first \
find what I want with below code in sqlite.after that I use the other code with regix \
to highlight results.<br></span></pre><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">and another reason is that its gonna be \
faster.And I can not count results in sqlite if there are more that on results in a \
row.<br></span></pre><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"><br>with </span>conn:<br>    cur = \
conn.cursor()<br>    conn.text_factory = <span \
style="color:rgb(0,0,128)">str<br></span><span style="color:rgb(0,0,128)">   \
</span><span style="color:rgb(0,128,128);font-weight:bold"></span><span \
style="color:rgb(0,128,128);font-weight:bold">   </span><br>        qury = (<span \
style="color:rgb(0,128,128);font-weight:bold">&quot; SELECT * FROM Translation WHERE \
table LIKE &#39;%{0}%&#39;;&quot;</span>).format(<span \
style="color:rgb(148,85,141)">self</span>.<wbr>lineEdit.text())<br>        \
cur.execute(qury)<br>        <span style="color:rgb(148,85,141)">self</span>.all_rows \
= cur.fetchall()<br>        a = <span style="color:rgb(0,0,255)">1<br></span><span \
style="color:rgb(0,0,255)">        </span><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:<br>            <span \
style="color:rgb(148,85,141)">self</span>.SearchResults.append(<span \
style="color:rgb(0,128,128);font-weight:bold">&#39;{0} )- {1} </span><span \
style="color:rgb(0,128,128);font-weight:bold;font-family:&quot;Aldhabi&quot;">﴿</span><span \
style="color:rgb(0,128,128);font-weight:bold"> {2}:mjp ={3} </span><span \
style="color:rgb(0,128,128);font-weight:bold;font-family:&quot;Aldhabi&quot;">﴾</span><span \
style="color:rgb(0,128,128);font-weight:bold">&#39;</span>.format(a, row[<span \
style="color:rgb(0,0,255)">4</span>], row[<span style="color:rgb(0,0,255)">2</span>], \
row[<span style="color:rgb(0,0,255)">1</span>]))<br>            <span \
style="color:rgb(148,85,141)">self</span>.SearchResults.append(<span \
style="color:rgb(0,128,128);font-weight:bold">&#39;{0} &#39;</span>.format((row[<span \
style="color:rgb(0,0,255)">3</span>])))<br>            <span \
style="color:rgb(148,85,141)">self</span>.SearchResults.append(<span \
style="color:rgb(0,128,128);font-weight:bold">&quot;&quot;</span>)<br>            a = \
a + <span style="color:rgb(0,0,255)">1</span></pre></div><div class="HOEnZb"><div \
class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 19, 2018 \
at 8:49 PM, Maziar Parsijani <span dir="ltr">&lt;<a \
href="mailto:maziar.parsijani@gmail.com" \
target="_blank">maziar.parsijani@gmail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr">Yes thats not help full because it is \
important for me to foreground the results all together. For example: &quot;Hello \
world&quot;is my text when I want to search &quot;l&quot;I want it to be highlighted \
.I couldn&#39;t do that with QTextEdit::find.</div><div \
class="m_-1449719062602015107HOEnZb"><div class="m_-1449719062602015107h5"><div \
class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 19, 2018 at 8:34 PM, \
Florian Bruhin <span dir="ltr">&lt;<a href="mailto:me@the-compiler.org" \
target="_blank">me@the-compiler.org</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><span>On Sun, Aug 19, 2018 at 08:31:13PM +0430, Maziar \
Parsijani wrote:<br> &gt; I use the below code to search in qtextedit to match a \
word.Are there any<br> &gt; better Idea.<br>
<br>
</span>Are you aware that there&#39;s a QTextEdit::find method?<br>
<span class="m_-1449719062602015107m_-5458833743828246069HOEnZb"><font \
color="#888888"><br> Florian<br>
<br>
-- <br>
<a href="https://www.qutebrowser.org" rel="noreferrer" \
target="_blank">https://www.qutebrowser.org</a> | <a \
href="mailto:me@the-compiler.org" target="_blank">me@the-compiler.org</a> \
                (Mail/XMPP)<br>
     GPG: 916E B0C8 FD55 A072 | <a href="https://the-compiler.org/pubkey.asc" \
                rel="noreferrer" \
                target="_blank">https://the-compiler.org/pubke<wbr>y.asc</a><br>
              I love long mails! | <a href="https://email.is-not-s.ms/" \
rel="noreferrer" target="_blank">https://email.is-not-s.ms/</a><br> \
</font></span></blockquote></div><br></div> </div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></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