PDA

View Full Version : QDateEdit With DataMapper - No Tab traversing?



fifth
1st July 2008, 00:12
Not sure if this is a qt, pyqt (or something in my os environment)
problem, but...

I have a QDateEdit widget which is mapped to a database date field.
The issue I have is ...

I can tab into the widget, ie into the 'dd' of 'dd/MM/yyyy' but cannot
tab onto the 'MM' and from MM cannot tab to 'yyyy'. However, I can tab
from 'yyyy' to another control.

If I comment out the datamapper line then I can use tab as expected.

I have checked the book examples from Rapid GUI Programming with
Python and PyQt and see the same problem there.

My versions are 'Python 2.5.2 - Qt 4.3.4- PyQt 4.3.3 on Linux 2.6.24-19-generic'.
However, I've also tested this on WinXP using a PyQt-Py2.5-gpl-4.4.2-1 install
with the same results.

Any help would be much appreciated as this is kinda a show stopper for
me - I am trying to make this form as quick as possible to use for
processing orders.

Chris.

fifth
1st July 2008, 20:42
Can anyone confirm if this is expected behaviour? Also a quick (python) example of the issue,



#!/usr/bin/env python
import os
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtSql import *

class ExampleDlg(QDialog):

def __init__(self, parent=None):
super(ExampleDlg, self).__init__(parent)

label1 = QLabel("First Edit:")
self.edit1 = QLineEdit()
label2 = QLabel("Unmapped:")
self.dateTime1 = QDateTimeEdit()
label3 = QLabel("Mapped:")
self.dateTime2 = QDateTimeEdit()
label4 = QLabel("Second Edit:")
self.edit2 = QLineEdit()

fieldLayout = QGridLayout()
fieldLayout.addWidget(label1, 0, 0)
fieldLayout.addWidget(self.edit1, 0, 1, 1, 3)
fieldLayout.addWidget(label2, 1, 0)
fieldLayout.addWidget(self.dateTime1, 1, 1)
fieldLayout.addWidget(label3, 1, 2)
fieldLayout.addWidget(self.dateTime2, 1, 3)
fieldLayout.addWidget(label4, 2, 0)
fieldLayout.addWidget(self.edit2, 2, 1, 1, 3)
self.setLayout(fieldLayout)

self.model = QSqlRelationalTableModel(self)
self.model.setTable("calls")
self.model.select()

self.mapper = QDataWidgetMapper(self)
self.mapper.setSubmitPolicy(QDataWidgetMapper.Manu alSubmit)
self.mapper.setModel(self.model)
self.mapper.setItemDelegate(QSqlRelationalDelegate (self))
self.mapper.addMapping(self.edit1, 1)
#self.mapper.addMapping(self.dateTime1, 2)
self.mapper.addMapping(self.dateTime2, 3)
self.mapper.addMapping(self.edit2, 4)
self.mapper.toFirst()

app = QApplication(sys.argv)
filename = os.path.join(os.path.dirname(__file__), "example.db")
db = QSqlDatabase.addDatabase("QSQLITE")
db.setDatabaseName(filename)
if not db.open():
sys.exit(1)
form = ExampleDlg()
form.show()
sys.exit(app.exec_())


I've noticed you can still navigate through the QDateEdit using the cursor keys or by entering values, but would expect to be able to navigate through the form widgets using tab.

fifth
5th July 2008, 14:26
Anyone?

I'm struggling with this. Is there any way I can capture the key event for Tab and change the QDateEdit section by code?