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. I have a QScrollArea and I want to disable arrow keys shortcut from horizontalScrollBar() and verticalScrollBar(). I want the keys to be disabled when I press the shift key.How I can reimplement the QScrollArea such that will work ?
Qt 6.11 is out! See what's new in the release blog

I have a QScrollArea and I want to disable arrow keys shortcut from horizontalScrollBar() and verticalScrollBar(). I want the keys to be disabled when I press the shift key.How I can reimplement the QScrollArea such that will work ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 335 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.
  • Z Offline
    Z Offline
    Zetsil
    wrote on last edited by Zetsil
    #1

    m_scrollArea->viewport()->installEventFilter(this); // I try this
    m_scrollArea->verticalScrollBar()->installEventFilter(this);

    bool ImageView::eventFilter(QObject *obj, QEvent *event)
    {

    if ( event->type() == QEvent::ShortcutOverride && obj == m_scrollArea->verticalScrollBar() ) //it dosen t filter it
    {
    QKeyEvent keyEvent = static_cast<QKeyEvent>(event);
    if(obj == keyEvent->key() == Qt::Key_Up)
    {
    m_scrollArea->verticalScrollBar()->setEnabled(false);
    std::cout<<" Up "<<std::endl;
    }
    }

    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