[Kde-pim] QComboBox/ItemDelegate question

Tobias Koenig tokoe at kde.org
Wed Nov 4 13:26:08 GMT 2009


Hej,

I currently try to improve the 'display name' handling in KAddressBook
by using a QComboBox instead of a QLineEdit to allow the user to select
different types of the display name (e.g. normal, reverse, reverse with comma).

So if the user has typed in 'Tobias Koenig Jr.' in the name edit, the display name
combo box will contain the following entries (when opening the popup menu):

  | Tobias Koenig     |
  | Tobias Koenig Jr. |
  | Koenig, Tobias    |
  | Koenig Tobias     |
  |                   |
  | Tobias Koenig     |

Now you might ask what is the difference between the first and the last entry
and why is the last but one entry empty? To clarify that, I'd like to add descriptions
in grey and italic font, so it would look like the following:

  | Tobias Koenig      [Short Name]         |
  | Tobias Koenig Jr.  [Full Name]          |
  | Koenig, Tobias     [Reverse with Comma] |
  | Koenig Tobias      [Reverse Name]       |
  |                    [Organization]       |
  | Tobias Koenig      [Custom Name]        |

Adding the additional text in the proper format is no problem by applying an
ItemDelegate to the QComboBox::view(), however though I reimplemented the
QAbstractItemDelegate::sizeHint() method to return a fitting width, the popup menu
is still too small, so half of the descriptions are cut away.
It seems the width of the popup is aligned to the width of the combobox itself.

Does one of you know a trick how the popup menu can be enforced to a given width?

Ciao,
Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20091104/ca674bbe/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list