[Qt-interest] shortcut(Qt::CTRL + Qt::Key_Plus) does not work.

Jason A. Donenfeld Jason at zx2c4.com
Thu Mar 31 18:47:26 CEST 2011


Hello James,

Do something like this instead:

QAction *zoomOutAction = toolbar->addAction(QIcon::fromTheme(QLatin1String("
zoom-out"), QIcon(QLatin1String(":icons/zoom-out.png"))), tr("Zoom &Out"),
this, SLOT(zoomOut()));

zoomOutAction->setAutoRepeat(*true*);

zoomOutAction->setShortcut(QKeySequence(QKeySequence::ZoomOut));

QAction *zoomInAction = toolbar->addAction(QIcon::fromTheme(QLatin1String("
zoom-in"), QIcon(QLatin1String(":icons/zoom-in.png"))), tr("Zoom &In"), this,
SLOT(zoomIn()));

zoomInAction->setAutoRepeat(*true*);

zoomInAction->setShortcut(QKeySequence(QKeySequence::ZoomIn));


Notice the usage of QKeySequence::Zoom{Out,In}, which will snag the
platform's local prefs for this.

Jason

On Wed, Mar 30, 2011 at 00:34, James Yan <james.pizza at gmail.com> wrote:

> Hey all,
>
>   I've two menu action: "Zoom In" and "Zoom Out", and i set shortcut for
> both of them,
> but only Zoom Out works (Qt::CTRL + Qt::Key_Minus), what's wrong with the
> zoom-in shortcut(Qt::CTRL + Qt::Key_Plus)?
>   a bug? thanks.
>
> ===
> actViewZoomIn  = new QAction("Zoom In",this);
> actViewZoomIn->setShortcut( QKeySequence(Qt::CTRL + Qt::Key_Plus ) );
>
> actViewZoomOut = new QAction("Zoom Out",this);
> actViewZoomOut->setShortcut( QKeySequence(Qt::CTRL + Qt::Key_Minus ) );
>
> ===
>
>
> regards,
>
> James
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>


-- 
Jason A. Donenfeld
Deep Space Explorer
+1-513-476-1200
www.jasondonenfeld.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110331/4bfd9870/attachment.html 


More information about the Qt-interest-old mailing list