Results 1 to 20 of 27

Thread: How to start the log file when key combinations pressed??

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    10
    Thanked 13 Times in 12 Posts

    Default How to start the log file when key combinations pressed??

    how to start the log file when CTRL+ALT+T is pressed and if it presssed again it should stop.... how it can be done...

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to start the log file when key combinations pressed??

    What is it exactly that you don't know how to implement?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    10
    Thanked 13 Times in 12 Posts

    Default Re: How to start the log file when key combinations pressed??

    I want to start the log file creation when CTRL+ALT+L is presssed and have to stop it when the same combination has been clicked.. please help me..

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to start the log file when key combinations pressed??

    I understand what you want, I'm asking what are you having problems with? Tell us what you have already tried and what didn't work.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    10
    Thanked 13 Times in 12 Posts

    Default Re: How to start the log file when key combinations pressed??

    Qt Code:
    1. void QCDevice::keyPressEvent(QKeyEvent *event)
    2. {
    3. if (event->key() == Qt::Key_Control && Qt::Key_Alt && Qt::Key_V) {
    4.  
    5. QMessageBox::warning(NULL,"Keypress","Keypressed",QMessageBox::Ok);
    6. }
    7.  
    8. I have tried this one, but after pressing the key combination also the message box is not shown..
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to start the log file when key combinations pressed??

    Is QCDevice a widget?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    10
    Thanked 13 Times in 12 Posts

    Default Re: How to start the log file when key combinations pressed??

    No its a dialog

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to start the log file when key combinations pressed??

    A dialog is also a widget Ok, does it have keyboard focus?

    Furthermore your code is incorrect:
    Qt Code:
    1. if (event->key() == Qt::Key_Control && Qt::Key_Alt && Qt::Key_V)
    To copy to clipboard, switch view to plain text mode 
    this can be translated to:
    Qt Code:
    1. if(event->key() == Qt::Key_Control && 0x01000023 && 0x56)
    To copy to clipboard, switch view to plain text mode 
    which again translates to:
    Qt Code:
    1. if(event->key() == Qt::Key_Control && true && true)
    To copy to clipboard, switch view to plain text mode 
    and then to:
    Qt Code:
    1. if(event->key() == Qt::Key_Control)
    To copy to clipboard, switch view to plain text mode 
    which as you probably guess is not what you want. Read what QKeyEvent::key() is and use it with conjunction with QKeyEvent::modifiers(). Or just use QShortcut.

    Learning a bit more C++ wouldn't hurt either.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    10
    Thanked 13 Times in 12 Posts

    Default Re: How to start the log file when key combinations pressed??

    How to perform those key combinations in it?? please help me with the above codes.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to start the log file when key combinations pressed??

    What didn't you understand from my previous post? Make sure you widget accepts focus, use QKeyEvent::key() in conjunction with QKeyEvent::modifiers() or use QShortcut. If you expect me to provide full working code then that's not going to happen, I rarely do that in the Newbie forum. And please correct your profile information, somehow I doubt you're using Qt3 or Qt/Embedded.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: How to start the log file when key combinations pressed??

    please help me with the above codes.
    You are using logical AND where you want bit-wise AND.

    http://en.wikipedia.org/wiki/Operato...ical_operators

  12. #12
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    10
    Thanked 13 Times in 12 Posts

    Default How to capture the key press events in QT in windows7??

    How to capture the key press events in QT in windows7?? CTRL+ALT+ some alphabet combination's. if we press this combination.. the particular event function should be called...

  13. #13
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    5
    Thanked 86 Times in 81 Posts

    Default Re: How to capture the key press events in QT in windows7??

    If you have a GUI application you can use QShortcut or QAction.
    A camel can go 14 days without drink,
    I can't!!!

  14. #14
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    10
    Thanked 13 Times in 12 Posts

    Default Re: How to capture the key press events in QT in windows7??

    I have used the following code.. it works fine in xp(Qt 1.3.1) but it is not working in windows 7.,(Qt 4.3)::

    Qt Code:
    1. QShortcut *shortcut = new QShortcut(QKeySequence("Ctrl+M"), this);
    2. QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(showmessage()));
    To copy to clipboard, switch view to plain text mode 

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to capture the key press events in QT in windows7??

    For the last time: shortcuts, key events and such work in terms of focus. One of children of the window containing the shortcut needs to have focus for the shortcut to trigger.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 4
    Last Post: 16th September 2011, 02:10
  2. Replies: 6
    Last Post: 4th October 2010, 03:19
  3. Capture key & key combinations from keyboard
    By aikidorb in forum Qt Programming
    Replies: 3
    Last Post: 5th June 2010, 13:13
  4. Start a exe file with parameters
    By raphaelf in forum Qt Programming
    Replies: 11
    Last Post: 17th June 2008, 09:11
  5. Getting the row for button pressed
    By steg90 in forum Qt Programming
    Replies: 2
    Last Post: 28th November 2007, 15:45

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.