Results 1 to 18 of 18

Thread: Shortcut: CTRL + SHIFT + "letters"

  1. #1
    Join Date
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Shortcut: CTRL + SHIFT + "letters"

    Hi,
    im having a problem with 3 key shortcut. I'm trying to add to an action this:
    Qt Code:
    1. action->->setShortcut(QKeySequence( (Qt::CTRL+Qt::SHIFT), Qt::Key_1))
    To copy to clipboard, switch view to plain text mode 
    but isn't trigeer, does anyone have an idea how to implement a 3 Key Shortcut??

    THANKS

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

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    Shouldn't it be:
    Qt Code:
    1. QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_1)
    To copy to clipboard, switch view to plain text mode 
    ?
    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
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    OH YEAH, im sorry, wrong code :P but QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_1) also didn't work and QKeySequence(Qt::CTRL,Qt::SHIFT,Qt::Key_1). My concern is if it is able to do it... or somebody have same problems. I have also 2 keys shortcuts in the same class and there are fine.

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

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    Try:
    Qt Code:
    1. QKeySequence("Ctrl+Shift+1")
    To copy to clipboard, switch view to plain text mode 
    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
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    nothing... I changed it to
    Qt Code:
    1. QKeySequence(tr("Ctrl+Shift+1"))
    To copy to clipboard, switch view to plain text mode 
    but nothing has trigger. Put on it a breakpoint to verify that isn't triggering.

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

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    So obviously the reason is not here. Can we see a larger snippet of code? How do you create and use the action?
    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
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    Qt Code:
    1. void QtContactMenu::createSortMenu( QObject* parent )
    2. {
    3.  
    4.  
    5. createAction( &_actionSortAlpha, pMenu, tr("Alphabetically"), true, QtEnumSortOption::SortAlpha, "", QKeySequence(tr("Ctrl+Shift+1")) );
    6. createAction( &_actionSortPresence, pMenu, tr("Presence"), true, QtEnumSortOption::SortPresence, "", QKeySequence(tr("Ctrl+Shift+2")) );
    7. createAction( &_actionSortRandom, pMenu, tr("Random"), true, QtEnumSortOption::SortRandom, "", QKeySequence(tr("Ctrl+Shift+3")) );
    8.  
    9. }
    10.  
    11. void QtContactMenu2::createAction( QAction** ppAction, QMenu* pMenu, const QString& text, bool bCheckable, int data, const char* iconPath, QKeySequence & shortcut ){
    12. *ppAction = new QAction( text, NULL ); //, parent );
    13.  
    14. (*ppAction)->setCheckable( bCheckable );
    15. (*ppAction)->setData(qVariantFromValue(data) );
    16.  
    17. if ( iconPath && (strlen( iconPath ) > 0 ) )
    18. {
    19. QIcon icon1;
    20. icon1.addPixmap(QPixmap( QString::fromUtf8(iconPath)), QIcon::Normal, QIcon::Off);
    21. (*ppAction)->setIcon(icon1);
    22. }
    23. if (shortcut){
    24. (*ppAction)->setShortcut(shortcut);
    25. }
    26. pMenu->addAction( *ppAction );
    27.  
    28. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    First of all please provide a parent for the action.
    What is pMenu (I mean the base class of it)? Is it visible anywhere on the screen?
    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
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    pMenu is a QMenu object, thats the menu on the app.

    What difference makes the parent?? I'm asking because if you set this:
    Qt Code:
    1. createAction( &_actionSortAlpha, pMenu, tr("Alphabetically"), true, QtEnumSortOption::SortAlpha, "", QKeySequence(tr("Ctrl+1")) );
    To copy to clipboard, switch view to plain text mode 

    this shortcut works without any problem...

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

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    This works for me just fine:
    Qt Code:
    1. #include <QtGui>
    2.  
    3.  
    4. int main(int argc, char **argv){
    5. QApplication app(argc, argv);
    6. QAction *act = new QAction(&app);
    7. act->setText("text");
    8. act->setShortcut(QKeySequence("Ctrl+Shift+1"));
    9. pb.setDefaultAction(act);
    10. QObject::connect(act, SIGNAL(triggered()), &app, SLOT(quit()));
    11. pb.show();
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

    The only reason I can think of is that the menu is not the active widget and thus the action is inactive. But then the second snippet you posted shouldn't have worked as well.
    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
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    thats the wear part, 2 keys works but 3 dont.

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

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    Could you test if my example works for you?
    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.


  13. #13
    Join Date
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: Shortcut: CTRL + SHIFT + "letters"

    Hey Wisota, is working but only with keyboard numbers, the numbers on the numpad of the keyboard dont react on it, I do it just once but no more.... Are keyboard nums and numpad nums different for QT??

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

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    Do you have NumLock enabled on your keyboard?
    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.


  15. #15
    Join Date
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    Yeap With or Without the NumLock, Keyboard nums works but NumPad don't

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

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    Quote Originally Posted by smarinr View Post
    Yeap With or Without the NumLock, Keyboard nums works but NumPad don't
    It works for me just fine when using the numeric key pad with NumLock active. Or at least with a pseudo-keypad (I have a laptop without a real keypad, only one made of special function keys).
    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.


  17. #17
    Join Date
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    Maybe.... im not pressing CRTL + SHIFT + 1 but I'm pressing CTL + ! (which is SHIFT + 1)> That why sometimes works

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

    Default Re: Shortcut: CTRL + SHIFT + "letters"

    I don't know what you are pressing "!" is "!", "Shift+1" is "Shift+1". You can have different keyboard layouts and some of them won't have "!" as "Shift+1". It works for me when I press Ctrl, Shift and 1.
    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: 1
    Last Post: 8th March 2007, 10:12

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.