Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6100621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:24:28+00:00 2026-05-23T13:24:28+00:00

Simple code demonstrating the problem: #!/usr/bin/env python import sys from PyQt4.QtCore import QObject, SIGNAL

  • 0

Simple code demonstrating the problem:

#!/usr/bin/env python

import sys
from PyQt4.QtCore import QObject, SIGNAL
from PyQt4.QtGui import QApplication, QTextEdit

app = QApplication(sys.argv)

def findText():
    print(textEdit.find('A'))

textEdit = QTextEdit()
textEdit.show()
QObject.connect(textEdit, SIGNAL('textChanged()'), findText)
sys.exit(app.exec_())

After typing ‘A’ into the window, find('A') still returns False.

Where is the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:24:29+00:00Added an answer on May 23, 2026 at 1:24 pm

    The problem is the position of the cursor in the window.

    By default – unless you specify some flags to be passed to the find() function, the search only happens forward (= from the position of the cursor onwards).

    In order to make your test work, you should do something like this:

    1. Run the program.
    2. Go to the window and type BA
    3. Move your cursor to the beginning of the line
    4. Type C

    This way you will have in the window the string CBA, with the cursor between C and B and the string onto which the find() method will work returning True will be BA.

    Alternatively you can test this other version of your code that has the backward flag set.

    #!/usr/bin/env python
    # -*- coding: utf-8  -*-
    
    import sys
    from PyQt4.QtCore import QObject, SIGNAL
    from PyQt4.QtGui import QApplication, QTextEdit, QTextDocument
    
    app = QApplication(sys.argv)
    
    def findText():
        flag = QTextDocument.FindBackward
        print(textEdit.toPlainText(), textEdit.find('A', flag))
    
    textEdit = QTextEdit()
    textEdit.show()
    QObject.connect(textEdit, SIGNAL('textChanged()'), findText)
    sys.exit(app.exec_())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the Apple documentation for NSRunLoop there is sample code demonstrating suspending execution while
Simple code: >>> set([2,2,1,2,2,2,3,3,5,1]) set([1, 2, 3, 5]) Ok, in the resulting sets there
This simple code is not producing any sound on a couple of machines that
So here is the simple code: [System.ComponentModel.DefaultValue(true)] public bool AnyValue { get; set; }
I have some very simple code to generate an assembly and invoke a method
This very simple code gives me tons of errors: #include <iostream> #include <string> int
I'm coding a simple code editor for a very simple scripting language we use
I've got such a simple code: <div class=div1> <div class=div2>Foo</div> <div class=div3> <div class=div4>
Looking for free/opensource code or description of algorithms to code (simple) and decode (hard)
Hopefully this is a simple one, but can anyone provide some simple c# code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.