textEdit takes 4 seconds to show up the text
-
@adrian88888888
You give your PyQt version but not your Qt version. Make sure they are consistent.To simplify your situation you can create an app which is only a
QLineEdit
. NoQMainWindow
, no layouts. E.g replace yourwindow = MainWindow()
bywindow = QLineEdit()
. Any different behaviour? -
@JonB Yes I can simplify it more, i didn't knew I could replace
window = MainWindow()
bywindow = QLineEdit()
This is the code as simplified as possible:
import sys from PySide2.QtWidgets import * app = QApplication(sys.argv) window = QLineEdit() window.show() sys.exit(app.exec_())
and the delay keeps being there, can you run this simple code and check out the fact that is not my system?
Qt version: 5.13.2
you mean that the versions have to be the same all the time(Qt and PyQt)? -
@adrian88888888 said in textEdit takes 4 seconds to show up the text:
you mean that the versions have to be the same all the time(Qt and PyQt)?
It helps :) Your are anyway.
No, this won't happen to the rest of us. A time delay every time we type characters into a
QLineEdit
? I think we would notice.If you can, try this in PyQt5 in case it's ...
WAIT!! You say you are using PyQt
PyQt version = 5.13.2
but you are
from PySide2.QtWidgets import *
Do you think this might be why you have a problem? :D
-
@JonB but i'm not supposed to use PySide2 in order to use Qt in python? as i understand pyside2 its the intermediate between qt and python?
or i'm all wrong?
now that you say, PyQt has a py in front for some reason, omg tell me that's it
what i'm supposed to import then?
oh no, this has a delay too:
import sys from PyQt5.QtWidgets import * app = QApplication(sys.argv) window = QLineEdit() window.show() sys.exit(app.exec_())
-
@adrian88888888
Not that any of the rest of us have it. But is this delay only if you rapidly type a few characters, or is it equally if you just type one character? And not in any other application, like Notepad? -
@JonB it is the same delay, doesn't matter what i type, i can type one letter and the delay its 4 seconds too
the delay happens at the first time i write in the textEdit, if i delete the text and start writing again the delay its gone
this happens only in this application, does not happen in notepad or others
-
@adrian88888888 said in textEdit takes 4 seconds to show up the text:
@JonB but i'm not supposed to use PySide2 in order to use Qt in python? as i understand pyside2 its the intermediate between qt and python?
PyQt is a different project that existed long before PySide2. It is also provided by a different company under a different set of licences.
-
i got no idea what to do, i reduced the problem to his minimum escence:
import sys from PyQt5.QtWidgets import * app = QApplication(sys.argv) window = QLineEdit() window.show() sys.exit(app.exec_())
what is the next step? i should report this as a bug? but i don't know if its a bug
can someone run this code and see? so i can uncheck the fact that i'm not crazy
at least i could know if its only me
-
@adrian88888888
Realistically: You would be best to uninstall everything, Qt itself in particular, both PyQt5 and PySide2. Reinstall from scratch. And/or, try on another PC.By all means what and see if anyone else is reporting that
QLineEdit
s have a 4 second delay. -
@adrian88888888
It would mean that the simplest Qt line edit program has a delay for everyone. Which would have been noticed.It is just possible that something is going on in the background while your program is still initializing, if you are typing into this line edit the moment you see the window. If you wait a few seconds before typing your first character, is there still a delay? It's mystifying :)
-
@adrian88888888
To keep you happy, I tried this on my system --- Ubuntu 20.04 (I think you are Windows), PyQt version: 5.14.1, Qt version: 5.12.8. I also tested with PySide2. As expected they behave fine, no delay.Try this little piece of code:
import sys from PyQt5.QtWidgets import * def textEdited(): print("Text edited") if __name__ == '__main__': app = QApplication(sys.argv) window = QLineEdit() window.textEdited.connect(textEdited) window.show() sys.exit(app.exec_())
If you run this from a Command Prompt ---
python path-to-your-file.py
--- it will printText edited
as soon as it detects a character press in yourQLineEdit
. For me that of course is immediate. What about for you? This distinguishes between when Qt sees the key press versus if there is some issue updating theQLineEdit
to show the character, if there is any discrepancy.The fact that you have "only* a
QTextEdit
should be neither here nor there. Of course you can build a more complex situation, but from what you showed earlier one would think you will have the same problem wherever you use aQLineEdit
.If you hadn't said you have tried on another PC and found same problem I would have said it was your PC. Since your problem occurs under both PyQt5 & PySide2 I would assume your problem lies in the Qt, or even the windowing system, not in the Python side. You presumably installed the same Qt version on both PCs? Can you try installing some other version of Qt to test?
-
@JonB You are being too generous with me for helping me all the way, i don't want to take more of your efforts
I just added some text and deleted it in the first run of the program, like this:
self.ui.textEdit.setText('hello world') self.ui.textEdit.setText('')
and the delay its gone with that
If for some reason if i need to fix this i will come back to it, but i really hope really bad to not have to fix this(because is so hard to troubleshoot)
Btw it looks that its something related with windows 10 because in your ubuntu works and i tried in 2 windows 10 machines and didn't work
printing "Text edited" has delay too