[Qt-interest] find/replace dialog

Mark Summerfield list at qtrac.plus.com
Mon Nov 30 09:54:39 CET 2009


Hi André,

On 2009-11-29, André Somers wrote:
> Hi,
> 
> While you point out a valid issue, I'm not sure I like your automatic
> assignment of accelerator keys either. Judging from the screenshot on your
> site only, I immediately spot some problems. The most obvious is the
> accelerator for Italic. Your application assigns that that to ALT+l. What
>  is unacceptable, I think. Practically *every* application uses uses the I
>  key here, I'd say. It would be confusing for a user if non-standard
>  accelerators would be used.

The alt_key library chooses "optimal" accelerators, which means it
prefers the first character, failing that the first character of a word,
and failing that any character. It has no rules or conventions built-in
for particular words.

It will always produce the maximum possible number of accelerators
without duplications. (Trying to do this manually, esp. when more than
15 or so accelerators is needed can be quite time consuming.)

However, it respects predefined accelerators, so in this case you would
just put in "&Italic" and alt_key will do the others (and won't use I
for any of them of course).

> Another problem that I see, is that the keys may seemingly randomly change
> between application versions. If between two application versions the
> strings used change, then existing functions may end up with another
> accelerator key. That doesn't sound like something my users would
> appreciate.
> 
> Perhaps I see it all wrong, but maybe you can comment on this?

For menus the changeability would be annoying. But you can always not
use alt_key for those or use predefined accelerators for those options
you don't ever want to see change.

The places where I see alt_key being of most use are:
- dynamic menus (e.g., the Window menu, the Recent Files submenu)
- dialogs
- applications that have lots of translations and where having
  accelerators at all is more important than consistency between
  versions

My recommended pattern of use would be: use alt_key for _all_ menus and
dialogs, but using manually inserted &s to support conventions ("&Save",
"&Copy" etc.), and for special cases. This will ensure that you always
have accelerators. And as time goes by you can always manually insert
more and more &s if you wish, to nail down those you don't want to
change.

> 
> André
> 
> -----Oorspronkelijk bericht-----
> Van: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] Namens Mark Summerfield
> Verzonden: zondag 29 november 2009 9:35
> Aan: qt-interest at trolltech.com
> CC: Lorenzo Bettini
> Onderwerp: Re: [Qt-interest] find/replace dialog
> 
> On 2009-11-28, Lorenzo Bettini wrote:
> > Hi
> >
> > some time ago I asked whether there is a reusable find/replace dialog,
> > but I was answered there's none.
> >
> > I tried to write one myself
> >
> > http://gitorious.org/qtfindreplacedialog
> >
> > any comment and contribution is welcome
> 
> Hi Lorenzo,
> 
> I noticed that in the screenshot on sourceforge you have a few duplicate
> keyboard accelerators ("&Find:" and "&Find", "&Close" and "&Case
> sensitive", and "R&eplace with" and "R&egular Expression").
> 
> I have a Qt program that lets you type in a list of texts (e.g., the
> labels and button texts used in a dialog, or the options in a menu,
> etc.), and produces a new list with keyboard accelerators and without
> duplicates. See:
> http://www.qtrac.eu/alt_key.html
> 
> In fact, the library that the program uses is fast enough to set
> keyboard accelerators dynamically, so you can embed it in your (GPL)
> code. Unfortunately I haven't yet documented the library, but it is easy
> to use nonetheless---just use one of the accelrate*() functions. (This
> library is used by almost all the examples in _Advanced Qt Programming_
> and has already saved me lots of time.).
> 


-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Advanced Qt Programming" - ISBN 0321635906




More information about the Qt-interest-old mailing list