[PyQt] Click on QTextEdit in a QDockWidget

Johan Marais johanperu at gmail.com
Sat Apr 10 21:35:37 BST 2010


Thanks for the help coming.

When I click on the QTextEdit Widget with the left button nothing happens
while it accepts the right button and I can process it from MousePressEvent. 
Please tell me where do I go wrong...  Any comments to this learner will be
accepted!  It seems it is only when I put the QTextEdit in a layout?

Thanks,  chaski



import os
import sys
from PyQt4.QtCore import (PYQT_VERSION_STR, QFile, QFileInfo, QSettings,
        QT_VERSION_STR, QTimer, Qt, SIGNAL,  QEvent) from PyQt4.QtGui import
*

class MainWindow(QMainWindow ):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
       
#layout:
        self.mainWidget=QWidget(self) # dummy widget
        self.setCentralWidget(self.mainWidget)

        self.mainLayout = QVBoxLayout(self.mainWidget)
        self.contentsList = QTextEdit()
        self.mainLayout.addWidget( self.contentsList )
       
    def mousePressEvent(self, event):
        print ("clicked" )

    def closeEvent(self, event):
        self.close()
       
###      

def main():
    app = QApplication(sys.argv)
    form = MainWindow()
    form.show()
    app.exec_()

main() 
-- 
View this message in context: http://old.nabble.com/Click-on-QTextEdit-in-a-QDockWidget-tp28204559p28204559.html
Sent from the PyQt mailing list archive at Nabble.com.



More information about the PyQt mailing list