Thank you for your reply wysota
"Reimplement the key event handler for your editor returned by the delegate or install an event filter on the editor and handle those keys in the filter."
I have done this on a subclassed QDoubleSpinbox:
void DoubleSpinBox
::keyPressEvent(QKeyEvent *e
) {
// UP
if(e->key() == Qt::Key_Launch6)
{
double value = this->text().toDouble();
value = value + singleStep;
emit valueChanged(value);
}
// DOWN
else if(e->key() == Qt::Key_Launch7)
{
double value = this->text().toDouble();
value = value - singleStep;
emit valueChanged(value);
}
}
void DoubleSpinBox::keyPressEvent(QKeyEvent *e)
{
// UP
if(e->key() == Qt::Key_Launch6)
{
double value = this->text().toDouble();
value = value + singleStep;
emit valueChanged(value);
}
// DOWN
else if(e->key() == Qt::Key_Launch7)
{
double value = this->text().toDouble();
value = value - singleStep;
emit valueChanged(value);
}
}
To copy to clipboard, switch view to plain text mode
...and runned the subclassed spinbox on the embedded system and it works alright.
But I still cant get the spinbox delegate example to work on the embedded system with an overrided keypress?
void MyTableWidget
::keyPressEvent(QKeyEvent *e
) {
switch(e->key())
{
case Qt::Key_Launch5:
{
}
break;
default:
break;
}
}
void MyTableWidget::keyPressEvent(QKeyEvent *e)
{
switch(e->key())
{
case Qt::Key_Launch5:
{
QAbstractItemView::edit(currentIndex(), QAbstractItemView::EditKeyPressed, e);
}
break;
default:
break;
}
QTableWidget::keyPressEvent(e);
}
To copy to clipboard, switch view to plain text mode
...open the cell to be edited but the spinbox delegate is still not called (createEditor and setEditorData)? I have taken your previous advice about stack allocation into thought, but I cant see that this is the case?
Bookmarks