×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    2

    qt listview problems

    Hey,
    I'm trying to do same pretty easy application for meamo 5 using QT (right now in PythonQT). I came to strange bugs in 4.5.3 version so I've upgraded to 4.6.2. Old errors disappeared however new one appeared.
    Maybe someone can provide some help or suggestion how to move forward.

    Here is complete story:

    with such libs:
    Code:
    [sbox-FREMANTLE_X86: ~] > dpkg -l python2.5-qt4* | grep ii
    ii  python2.5-qt4-common      4.7-maemo7     Shared files for PyQt4
    ii  python2.5-qt4-core        4.7-maemo7     Python bindings for Qt4 Core components.
    ii  python2.5-qt4-dbus        4.7-maemo7     Python bindings for Qt dbus mainloop.
    ii  python2.5-qt4-gui         4.7-maemo7     Python bindings for Qt4 Core components.
    [sbox-FREMANTLE_X86: ~] > dpkg -l libqt* | grep ii
    ii  libqt4-core        4.5.3~git20090723-0maemo6+0m5 Qt 4 core module
    ii  libqt4-gui         4.5.3~git20090723-0maemo6+0m5 Qt 4 GUI module
    Attached code looks like this:


    As you can see there is something wrong with checkboxes

    So I've updated to newest version of qt and pyton-qt

    Now I've following libs:
    Code:
    [sbox-FREMANTLE_X86: ~] > dpkg -l python2.5-qt4* | grep ii
    ii  python2.5-qt4-common      4.7.3-maemo2   Shared files for PyQt4
    ii  python2.5-qt4-core        4.7.3-maemo2   Python bindings for Qt4 Core components.
    ii  python2.5-qt4-dbus        4.7.3-maemo2   Python bindings for Qt dbus mainloop.
    ii  python2.5-qt4-gui         4.7.3-maemo2   Python bindings for Qt4 Core components.
    [sbox-FREMANTLE_X86: ~] > dpkg -l libqt* | grep ii
    ii  libqt4-core        4.6.2~git20100310-0maemo1+0m5 Qt 4 core module
    ii  libqt4-gui         4.6.2~git20100310-0maemo1+0m5 Qt 4 GUI module
    And application (at least checkbox) looks much better:


    However the same code that was previously working, with new libs doesn't. Once editor has been open - its widgets doesn't work (looks like they doesn't get events or maybe there is some problem with position translation).

    I've no idea what I'm doing wrong and why code that was working now doesn't.

    Thanks
    Kasper

    PS. Screenshots are taken from scratchbox but on real device it looks exactly the same
    _________________________ test_case.py ________________
    Code:
    import sys
    from PyQt4 import QtCore, QtGui
    from PyQt4.QtCore import *
    from PyQt4.QtGui import *
    
    
    class MyForm(QtGui.QWidget):
        def __init__(self, parent=None):
            QtGui.QWidget.__init__(self, parent)
                    
            list_data = ["item1","item2","item3","item4","item5"]
            
            lm = MyListModel(list_data,self)
            self.lv = QListView()
            self.lv.setModel(lm)
             #   print i
    
            self.mdelegate=MyDelegate(self.lv)
            self.lv.setItemDelegate(self.mdelegate)
    
            # layout
            layout = QVBoxLayout()
            layout.addWidget(self.lv) 
            self.setLayout(layout)
      
            
    class MyListModel(QAbstractListModel): 
        def __init__(self, datain, parent=None, *args): 
            QAbstractListModel.__init__(self, parent, *args) 
            self.listdata = datain
     
        def rowCount(self, parent=QModelIndex()): 
            return len(self.listdata) 
     
        def data(self, index, role): 
            if role==Qt.CheckStateRole:
                    return Qt.Checked        
            if index.isValid() and role == Qt.DisplayRole:
                return QVariant(self.listdata[index.row()])
            else: 
                return QVariant()
           
        def flags(self, index):
            return QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsDragEnabled |QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable | Qt.ItemIsEditable
            
           
    class MyDelegate(QStyledItemDelegate):
        def __init__(self, parent):
            QStyledItemDelegate.__init__(self, parent)
            self.editorState=False
              
        def createEditor(self, parent, option, index):
            editor=MyEditor(parent)
            return editor
            
        def sizeHint (self, option, index):
            return QStyledItemDelegate.sizeHint(self, option, index)+QSize(0, 0)
    
        def setEditorData( self, editor, index ):
            pass
          
        def updateEditorGeometry( self, editor, option, index ):
            editor.setGeometry(option.rect)
                            
    class MyEditor(QtGui.QWidget):
        def __init__(self, parent):
            QtGui.QWidget.__init__(self, parent)
            
            self.button = QtGui.QPushButton("Press me")
            layout = QVBoxLayout(parent)
            layout.addWidget(self.button) 
            self.setLayout(layout)
                  
            QtCore.QObject.connect(self.button, QtCore.SIGNAL("clicked()"), self.echo)
    
        def setValue(self, value):
            pass
        
        def echo(self):
            print "has been clicked"
        
    if __name__ == "__main__":
        app = QtGui.QApplication(sys.argv)
        myapp = MyForm()
        myapp.show()
        sys.exit(app.exec_())

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: qt listview problems

    Could you explain in more details what exactly is not working?

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    2

    Re: qt listview problems

    Thanks for reply.

    Did you try to hit button ?
    for me it doesn't work - perhaps I'm doing something in wrong way, however with previous version of qt lib I was able to get simple text on output "has been clicked" once button has been clicked.
    Maybe you want to connect signal clicked() with something else ... more visual
    There is also something else that may confirm that it is a bug not my fault - with newest version of qt please remove that line:
    self.lv.setItemDelegate(self.mdelegate)

    You will get a "fresh" QListView - now try to turn one of rows into editor state (it will be empty), try to write something and then try to mark with mouse a part of text. For me that failed. I've done a test and I've returned to 4.5.3. Now editing works fine.

Similar Threads

  1. Qt Creator code completion not working with Qt Mobility for Symbian
    By ceefour in forum [Archived] Qt Mobility Project
    Replies: 4
    Last Post: 2011-09-10, 05:02
  2. Publish to OVI using stripped down Qt static bin, Smart Installer release date?
    By marksmithdev in forum [Closed] Publishing to Nokia Store
    Replies: 2
    Last Post: 2010-05-18, 11:21
  3. [ANN] Running Adobe Flash and Silverlight in Qt apps
    By AlexLeo in forum News, Announcements and Job Listings
    Replies: 0
    Last Post: 2009-11-06, 07:04
  4. Several problems with NMIT 4.1 MMS
    By jtalviva in forum General Messaging
    Replies: 0
    Last Post: 2006-03-10, 11:03

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •