Page 1 of 2 12 LastLast
Results 1 to 20 of 27

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

  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 Re: How to start the log file when key combinations pressed??

    I have solved that

    Qt Code:
    1. if ((event->type()==QEvent::KeyPress) && (event->modifiers() & Qt::ControlModifier) &&
    2. (event->modifiers() & Qt::AltModifier)&& (event->key()==Qt::Key_L))
    3. {
    4. QMessageBox::warning(NULL,"keypress","key pressed",QMessageBox::Ok);
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 

  13. #13
    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??

    The above code works fine in xp .. But it Fails in windows 7.. please help me

  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 start the log file when key combinations pressed??

    In window 7 even the key press event is not called... please help me in fixing this...

  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 start the log file when key combinations pressed??

    Does the widget accept keyboard focus?
    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.


  16. #16
    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. it is not accepting it. but it works good in xp

  17. #17
    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??

    Quote Originally Posted by Gokulnathvc View Post
    No. it is not accepting it.
    So it won't handle key events.
    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.


  18. #18
    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??

    Whether it can be applied using the dialogs instead

  19. #19
    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??

    Quote Originally Posted by Gokulnathvc View Post
    Whether it can be applied using the dialogs instead
    I have no idea what you mean.
    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.


  20. #20
    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??

    Is it possible to apply the key press events for the dialog based applications???

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.