Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. CTRL+X/C/V/A for custom widgets

CTRL+X/C/V/A for custom widgets

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jake007
    wrote on last edited by
    #1

    Hi!

    I'd like to assign cut, copy, paste and select all shortcuts to a QGraphicsView widget.
    If I do this using menus (which is how I'd like to) and assign each action with its corresponding shortcut, I override shortcuts for all other widget ( QTextEdit, QLineEdit ...).

    How can I solve this?

    If possible, I'd like to have this actions listed in QMenu with shortcuts.

    I also looked over an alternative, overriding QGraphicsView::keyPressEvent, and may question is, is Qt::key_Copy for ctrl+c?

    Thanks in advance.

    Regards,
    Jake

    EDIT:
    It works with default widgets. It does not work with inherited QTextEdit and overridden keyPressEvent();

    Code:
    @void ConsoleOutput::keyPressEvent(QKeyEvent *e)
    {
    switch(e->key())
    {
    case Qt::Key_Enter:
    case Qt::Key_Return:
    emit returnPressed();
    output("<br />");
    break;
    case Qt::Key_Left:
    case Qt::Key_Right:
    case Qt::Key_Up:
    case Qt::Key_Down:
    break;
    default:
    cursorToEnd();
    }

    if(myFirstInput)
    {
    myFirstInput = false;

    myOrg = this->toPlainText();
    myLen = this->toPlainText().length();
    }

    else if(e->key() == Qt::Key_Backspace)
    {
    if(toPlainText().size() < myLen)
    return;

    else if(toPlainText()[(toPlainText().size()-1)] == '\n')
    return;
    }

    QTextEdit::keyPressEvent(e);
    }@


    Code is poetry

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jake007
      wrote on last edited by
      #2

      I pinpointed the problem.
      It's because I set widget to read only. If I do not, it works as it should.

      In my opinion it's a bug. Can someone confirm this? Ctrl + a and ctrl + c should work even if it's read only, since data is not changed.


      Code is poetry

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved