Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 508535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:55:02+00:00 2026-05-13T06:55:02+00:00

I have a problem with Qt 4.6.0 and shortcut for QPushButtons : I want

  • 0

I have a problem with Qt 4.6.0 and shortcut for QPushButtons :

I want to display a special text in a QTextEdit when the user clicks a button, but only when the button is pressed, as soon as it’s released, i want another text to come up.

Everything works fine but now I want to add a shortcut (let’s say F1) to perform the exact same operation, when I push F1 it displays something special in a QTextEdit ’til I release the key. How do I manage to do this ?

I added the shortCut on my button, but when I press F1, it’s blinking, it’s like as long as I press F1, lots of signals are being emitted… I want my QTextEdit to change when I press F1 and then change back when I release the key…

I hope my question is clear !

Thanks a lot in advance for your advices !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:55:03+00:00Added an answer on May 13, 2026 at 6:55 am

    I think the most simple solution to this problem is to use installEventFilter() on the parent object (the window), and filter out the QEvent::MouseButtonPress and QEvent::MouseButtonRelease events.

    bool MainWindow::eventFilter(QObject *obj, QEvent *event)
    {
     if (obj == textEdit) {
         if (event->type() == QEvent::KeyPress) {
             QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
             qDebug() << "Ate key press" << keyEvent->key();
             return true;
         } else {
             return false;
         }
     } else {
         // pass the event on to the parent class
         return QMainWindow::eventFilter(obj, event);
     }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem SIMILAR to preventing form data reposting, but not quite the same
I have a simple but realy annoying problem: I just can't manage to type
I have a created a custom keyboard shortcut for my application, when the user
i have one problem with this ?! i use this way for run only
Problem: to have a keyboard shortcut to google a current selection in Screen's copy
I have finished my program about encryption. The problem is, I need a shortcut.
I have a really strange problem with WPF. A simple window with a button
I have a problem which I guessed would be really simple to solve... but
I have a dropdown menu the expands on clicks rather than hover. The problem
I have problem with http://abfoodpolicy.com/ . In IE 8 and 9 the right sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.