Results 1 to 3 of 3

Thread: Trying to set shortcut

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Trying to set shortcut

    Better would be something like this !!

    Qt Code:
    1. QSignalMapper *signalMapper = new QSignalMapper(this);
    2. for( int index=0; index < tabWidget->count(); ++index ){
    3. QShortcut *shortcut =new QShortcut( QKeySequence(QString("Ctrl+F%1").arg( index +1 ) ), this );
    4.  
    5. connect( shortcut, SIGNAL(activated() ), signalMapper, SLOT( map() ) );
    6. signalMapper->setMapping( shortcut, index );
    7. }
    8. connect( signalMapper, SIGNAL(mapped( int )),
    9. tabWidget, SLOT(setCurrentIndex( int )) );
    To copy to clipboard, switch view to plain text mode 
    We can't solve problems by using the same kind of thinking we used when we created them

  2. The following user says thank you to sunil.thaha for this useful post:

    mikro (30th November 2006)

  3. #2
    Join Date
    Apr 2006
    Location
    Erlangen, Germany
    Posts
    58
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Trying to set shortcut

    thank you, that was what it needed. Hadn't seen that there is a QShortcut as well.
    now i can dub my app 1.0 PRE 1 )

Similar Threads

  1. QIde, a new IDE for Qt4
    By jlbrd in forum Qt-based Software
    Replies: 114
    Last Post: 4th October 2006, 21: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
  •  
Qt is a trademark of The Qt Company.