strange behavior with PyQt

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

  1. freud

    freud

    Joined:
    Aug 22, 2009
    Messages:
    1
    Likes Received:
    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 (Text):

    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. Advertisements

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:
    574
    sstark
    Mar 6, 2005
  2. ryang
    Replies:
    1
    Views:
    1,147
    Wes Groleau
    Apr 11, 2005
  3. Apogee

    Strange Behavior with ViewState

    Apogee, Jul 3, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    423
    Apogee
    Jul 3, 2003
  4. PJ

    DropDownList Strange Behavior

    PJ, Jul 8, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    444
  5. adlaird@earthlink.net

    Strange behavior with HttpCookieCollection

    adlaird@earthlink.net, Jul 19, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    404
    Chris R. Timmons
    Jul 19, 2003
  6. Mantorok Redgormor
    Replies:
    70
    Views:
    2,418
    Dan Pop
    Feb 17, 2004
  7. ulysses
    Replies:
    4
    Views:
    1,083
    Werner Schiendl
    Oct 22, 2003
  8. taco
    Replies:
    1
    Views:
    320
Loading...