I've implemented a dialog with two customized text-editor inside(Two editor objects with same class)
This custom widget is an inherited class from QWidget
and it has two widgets inside, one is a actions-tool-bar and second is a QTextEdit
. I set some shortcuts to this custom widget for some actions like 'Make text Bold', 'Make text Italic', so on.
here is a picture of these widgets inside of my dialog:
![Two custom Text-Edit inside a dialog][1]
[1]: https://i.sstatic.net/en3mw.png
So far every thing is ok. But, when I press Ctrl+B for example, I got this error message:
QAction::eventFilter: Ambiguous shortcut overload: Ctrl+B
setting the shortcut context to WidgetWithChildrenShortcut
won't help me to disambiguate shortcuts.
anyone has any other idea?
Finally, I found the solution. My editor was inherited from qtextedit. I add this lines to each action, and it works now!
void MyEditor::addActionToToolbar(QAction *a)
{
a->setShortcutContext(Qt::WidgetWithChildrenShortcut);
addAction(a);
QToolButton* btn = new QToolButton(this);
btn->setDefaultAction( a );
btn->setFocusPolicy(Qt::NoFocus);
btn->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
btn->setIconSize(QSize(16,16));
toolBar->addWidget(btn);
}