I already want that shortcuts work/active when I am in texteditor when typing! I do the shortcuts as ALT+A AND ALT+D when writing when I press ALT+A it works but when I do the shortcuts as CTRL+Key_Left and CTRL_Right it doesn't work it just goes to the next work or previous words( ctrl+key_left and ctrl+key_right are the shortcuts for these actions on any editor) the problem is I can't override them This a project and my theacher exactly wants CTRL+Key_Left and CTRL_Right to conrol the player it's ridicilious But I must do that.
the text edit is the mainwindow and the player is created in it like
TextEdit
::TextEdit(QWidget *parent
){...
MediaPlayer *player= new MediaPlayer(fileString, hasSmallScreen);
QWidget* player2
=qobject_cast<MediaPlayer
*>
(player
);
splitter->addWidget(player2);
splitter->addWidget(textEdit);
...
}
TextEdit::TextEdit(QWidget *parent)
: QMainWindow(parent)
{...
MediaPlayer *player= new MediaPlayer(fileString, hasSmallScreen);
QWidget* player2 =qobject_cast<MediaPlayer *>(player);
QSplitter *splitter = new QSplitter(Qt::Horizontal);
splitter->addWidget(player2);
splitter->addWidget(textEdit);
...
}
To copy to clipboard, switch view to plain text mode
I try this
TextEdit
::TextEdit(QWidget *parent
)...
shortcuts[SH_SLIDER_DOWN
] = new QShortcut(this);
shortcuts
[SH_SLIDER_DOWN
]->setKey
(QKeySequence(Qt
::CTRL+Qt
::Key_Left));
shortcuts
[SH_SLIDER_UP
] = new QShortcut(this);
shortcuts
[SH_SLIDER_UP
]->setKey
(QKeySequence(Qt
::ALT+Qt
::Key_D));
shortcuts
[SH_PLAYORPAUSE
] = new QShortcut(this);
shortcuts
[SH_PLAYORPAUSE
]->setKey
(QKeySequence(Qt
::ALT+Qt
::Key_W));
connect(shortcuts[SH_SLIDER_UP], SIGNAL(activated()), player, SLOT(stepForward()));
connect(shortcuts[SH_SLIDER_DOWN], SIGNAL(activatedAmbiguously()), player, SLOT(stepBackward()));
// I tried this too but nothing. connect(shortcuts[SH_SLIDER_DOWN], SIGNAL(activated()), player, SLOT(stepBackward()));
connect(shortcuts[SH_PLAYORPAUSE], SIGNAL(activated()), player, SLOT(playPause()));
...
}
TextEdit::TextEdit(QWidget *parent)
: QMainWindow(parent){
...
shortcuts[SH_SLIDER_DOWN] = new QShortcut(this);
shortcuts[SH_SLIDER_DOWN]->setKey(QKeySequence(Qt::CTRL+Qt::Key_Left));
shortcuts[SH_SLIDER_UP] = new QShortcut(this);
shortcuts[SH_SLIDER_UP]->setKey(QKeySequence(Qt::ALT+Qt::Key_D));
shortcuts[SH_PLAYORPAUSE] = new QShortcut(this);
shortcuts[SH_PLAYORPAUSE]->setKey(QKeySequence(Qt::ALT+Qt::Key_W));
connect(shortcuts[SH_SLIDER_UP], SIGNAL(activated()), player, SLOT(stepForward()));
connect(shortcuts[SH_SLIDER_DOWN], SIGNAL(activatedAmbiguously()), player, SLOT(stepBackward()));
// I tried this too but nothing. connect(shortcuts[SH_SLIDER_DOWN], SIGNAL(activated()), player, SLOT(stepBackward()));
connect(shortcuts[SH_PLAYORPAUSE], SIGNAL(activated()), player, SLOT(playPause()));
...
}
To copy to clipboard, switch view to plain text mode
But the CTRL+Key_Left just make the cursor posion previous word. I cant't override it.CTRL+Key_Left I think is a windows shortcut I don't know, it works in every where WORD, email or on this post
Bookmarks