I am trying to add shortcut that triggers the Enter key, but will not trigger.
I do not mean the Return key.
Example: I want to add shortcuts to table row when Return or Enter key is triggered and while the Return key does it's job well, the Enter key does nothing.
I've searched over the internet but all I can find was people that mistakenly used Enter key instead Return.
This is how I set them:
selectRow=new QShortcut(QKeySequence(Qt::Key_Return),table);
selectRow2=new QShortcut(QKeySequence(Qt::Key_Enter),table);
To copy to clipboard, switch view to plain text mode
This is how I connect them:
connect(selectRow,SIGNAL(activated()),this,SLOT(emitSelect()));
connect(selectRow2,SIGNAL(activated()),this,SLOT(emitSelect()));
connect(selectRow,SIGNAL(activated()),this,SLOT(emitSelect()));
connect(selectRow2,SIGNAL(activated()),this,SLOT(emitSelect()));
To copy to clipboard, switch view to plain text mode
The slot:
void WidgetClass::emitSelect(){
if(qmi.isValid())
emit selectedRowIdx(qmi);
}
void WidgetClass::emitSelect(){
QModelIndex qmi=table->currentIndex();
if(qmi.isValid())
emit selectedRowIdx(qmi);
}
To copy to clipboard, switch view to plain text mode
Bookmarks