strange behavior with PyQt

Joined
Aug 22, 2009
Messages
1
Reaction score
0
Hi,guys

I'm just starting using PyQt to make some simple apps, i need a custom widget, so i created a new calss named TextEdit which subclassed from QTextEdit ,but some strange behavior happened,when this new TextEdit is showed on the screen, when i clicked the right mousebutton ,the contextmenu pops up correctly, but when i choose the select all action,no text is selected or highlighted, so i keep on click the right mousebutton ,but nothing happened ,the context menu did not pop up again. After some effort, i find that if i use the shortcut (CTRL+A) the texts are selected correctly, i also find that if i put TextEdit and QTextEdit in the same app,the problem is gone.

Anyone has stumbled upon the same problem before,any suggestion is appreciated.
Here is my code,it's very simple,the new widget does nothing.

PyQt 4.5.4/Python3.1/WinXp SP3
Code:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
app=QApplication(sys.argv)
class TextEdit(QTextEdit):
    def __init__(self,parent=None):
        super(TextEdit,self).__init__(parent)

edit=TextEdit()
edit.show()
#if the following code doesn't comment out,everything is fine
#e=QTextEdit()
#e.show()
            
app.exec_()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top