strange behavior with PyQt

Discussion in 'Python' started by freud, Aug 22, 2009.

  1. freud

    freud

    Joined:
    Aug 22, 2009
    Messages:
    1
    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_()
    
     
    freud, Aug 22, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sstark
    Replies:
    0
    Views:
    477
    sstark
    Mar 6, 2005
  2. ryang
    Replies:
    1
    Views:
    987
    Wes Groleau
    Apr 11, 2005
  3. Mantorok Redgormor
    Replies:
    70
    Views:
    1,843
    Dan Pop
    Feb 17, 2004
  4. ulysses
    Replies:
    4
    Views:
    816
    Werner Schiendl
    Oct 22, 2003
  5. taco
    Replies:
    1
    Views:
    260
Loading...

Share This Page