PDA

View Full Version : QShortcuts with the same key, different widgets



BatteryCell
27th June 2007, 02:23
Hi, I create two shortcuts like this: (slotRemove is different in the two widgets)


QShortcut* del = new QShortcut(QKeySequence(Qt::Key_Delete),widget1);
connect(del, SIGNAL(activated()),widget1, SLOT(slotRemove()));

QShortcut* del2= new QShortcut(QKeySequence(Qt::Key_Delete),widget2);
connect(del2, SIGNAL(activated()),widget2,SLOT(slotRemove()));

where widget1 is a QTableWidget and widget2 is a QTableView with custom model. The problem is that if I press delete in the tree, the slot is called correctly, however if I then try to press delete in the table, nothing happens, and delete no longer works correctly in the tree. In fact, nothing happens at all after I try to 'switch' and press delete. The same happens if I reverse the order (table first, tree second). I tried to change the contexts, but it did not work. Am I missing something here?

BatteryCell
27th June 2007, 05:25
Nevermind, I fixed it by defining the ambiguous function as the same as the non ambiguous function.