Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

Q3IconViewItem Class Reference
[Qt3Support module]

The Q3IconViewItem class provides a single item in a Q3IconView. More...

 #include <Q3IconViewItem>

This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.

Public Functions

Protected Functions


Detailed Description

The Q3IconViewItem class provides a single item in a Q3IconView.

A Q3IconViewItem contains an icon, a string and optionally a sort key, and can display itself in a Q3IconView.

The simplest way to create a Q3IconViewItem and insert it into a Q3IconView is to construct the item passing the constructor a pointer to the icon view, a string and an icon:

 (void) new Q3IconViewItem(
                 iconView,        // A pointer to a Q3IconView
                 "This is the text of the item",
                 aPixmap);

By default the text of an icon view item may not be edited by the user but calling setRenameEnabled(true) will allow the user to perform in-place editing of the item's text.

When the icon view is deleted all items in it are deleted automatically.

The Q3IconView::firstItem() and Q3IconViewItem::nextItem() functions provide a means of iterating over all the items in a Q3IconView:

 Q3IconViewItem *item;
 for (item = iconView->firstItem(); item; item = item->nextItem())
     do_something_with(item);

The item's icon view is available from iconView(), and its position in the icon view from index().

The item's selection status is available from isSelected() and is set and controlled by setSelected() and isSelectable().

The text and icon can be set with setText() and setPixmap() and retrieved with text() and pixmap(). The item's sort key defaults to text() but may be set with setKey() and retrieved with key(). The comparison function, compare() uses key().

Items may be repositioned with move() and moveBy(). An item's geometry is available from rect(), x(), y(), width(), height(), size(), pos(), textRect() and pixmapRect(). You can also test against the position of a point with contains() and intersects().

To remove an item from an icon view, just delete the item. The Q3IconViewItem destructor removes it cleanly from its icon view.

Because the icon view is designed to use drag-and-drop, the icon view item also has functions for drag-and-drop which may be reimplemented.

The class is designed to be very similar to Q3ListView and Q3ListBox in use, both via instantiation and subclassing.


Member Function Documentation

Q3IconViewItem::Q3IconViewItem ( Q3IconView * parent )

Constructs a Q3IconViewItem and inserts it into icon view parent with no text and a default icon.

Q3IconViewItem::Q3IconViewItem ( Q3IconView * parent, Q3IconViewItem * after )

Constructs a Q3IconViewItem and inserts it into the icon view parent with no text and a default icon, after the icon view item after.

Q3IconViewItem::Q3IconViewItem ( Q3IconView * parent, const QString & text )

Constructs an icon view item and inserts it into the icon view parent using text as the text and a default icon.

Q3IconViewItem::Q3IconViewItem ( Q3IconView * parent, Q3IconViewItem * after, const QString & text )

Constructs an icon view item and inserts it into the icon view parent using text as the text and a default icon, after the icon view item after.

Q3IconViewItem::Q3IconViewItem ( Q3IconView * parent, const QString & text, const QPixmap & icon )

Constructs an icon view item and inserts it into the icon view parent using text as the text and icon as the icon.

Q3IconViewItem::Q3IconViewItem ( Q3IconView * parent, Q3IconViewItem * after, const QString & text, const QPixmap & icon )

Constructs an icon view item and inserts it into the icon view parent using text as the text and icon as the icon, after the icon view item after.

Q3IconViewItem::Q3IconViewItem ( Q3IconView * parent, const QString & text, const QPicture & picture )

Constructs an icon view item and inserts it into the icon view parent using text as the text and picture as the icon.

Q3IconViewItem::Q3IconViewItem ( Q3IconView * parent, Q3IconViewItem * after, const QString & text, const QPicture & picture )

Constructs an icon view item and inserts it into the icon view parent using text as the text and picture as the icon, after the icon view item after.

Q3IconViewItem::~Q3IconViewItem ()   [virtual]

Destroys the icon view item and tells the parent icon view that the item has been destroyed.

bool Q3IconViewItem::acceptDrop ( const QMimeSource * mime ) const   [virtual]

Returns true if you can drop things with a QMimeSource of mime onto this item; otherwise returns false.

The default implementation always returns false. You must subclass Q3IconViewItem and reimplement acceptDrop() to accept drops.

void Q3IconViewItem::calcRect ( const QString & text_ = QString() )   [virtual protected]

This virtual function is responsible for calculating the rectangles returned by rect(), textRect() and pixmapRect(). setRect(), setTextRect() and setPixmapRect() are provided mainly for reimplementations of this function.

text_ is an internal parameter which defaults to an empty string.

int Q3IconViewItem::compare ( Q3IconViewItem * i ) const   [virtual]

Compares this icon view item to i. Returns -1 if this item is less than i, 0 if they are equal, and 1 if this icon view item is greater than i.

The default implementation compares the item keys (key()) using QString::localeAwareCompare(). A reimplementation may use different values and a different comparison function. Here is a reimplementation that uses plain Unicode comparison:

 int MyIconViewItem::compare(Q3IconViewItem *i) const
 {
     return key().compare(i->key());
 }

See also key(), QString::localeAwareCompare(), and QString::compare().

bool Q3IconViewItem::contains ( const QPoint & pnt ) const

Returns true if the item contains the point pnt (in contents coordinates); otherwise returns false.

bool Q3IconViewItem::dragEnabled () const

Returns true if the user is allowed to drag the icon view item; otherwise returns false.

See also setDragEnabled().

void Q3IconViewItem::dragEntered ()   [virtual protected]

This function is called when a drag enters the item's bounding rectangle.

The default implementation does nothing; subclasses may reimplement this function.

void Q3IconViewItem::dragLeft ()   [virtual protected]

This function is called when a drag leaves the item's bounding rectangle.

The default implementation does nothing; subclasses may reimplement this function.

bool Q3IconViewItem::dropEnabled () const

Returns true if the user is allowed to drop something onto the item; otherwise returns false.

See also setDropEnabled().

void Q3IconViewItem::dropped ( QDropEvent * e, const Q3ValueList<Q3IconDragItem> & lst )   [virtual protected]

This function is called when something is dropped on the item. e provides all the information about the drop. If the drag object of the drop was a Q3IconDrag, lst contains the list of the dropped items. You can get the data by calling Q3IconDragItem::data() on each item. If the lst is empty, i.e. the drag was not a Q3IconDrag, you must decode the data in e and work with that.

The default implementation does nothing; subclasses may reimplement this function.

int Q3IconViewItem::height () const

Returns the height of the item.

Q3IconView * Q3IconViewItem::iconView () const

Returns a pointer to this item's icon view parent.

int Q3IconViewItem::index () const

Returns the index of this item in the icon view, or -1 if an error occurred.

bool Q3IconViewItem::intersects ( const QRect & r ) const

Returns true if the item intersects the rectangle r (in contents coordinates); otherwise returns false.

bool Q3IconViewItem::isSelectable () const

Returns true if the item is selectable; otherwise returns false.

See also setSelectable().

bool Q3IconViewItem::isSelected () const

Returns true if the item is selected; otherwise returns false.

See also setSelected().

QString Q3IconViewItem::key () const   [virtual]

Returns the key of the icon view item or text() if no key has been explicitly set.

See also setKey() and compare().

bool Q3IconViewItem::move ( int x, int y )   [virtual]

Moves the item to position (x, y) in the icon view (these are contents coordinates). Returns true if the item is moved. Returns false if the item is already at the specified position.

bool Q3IconViewItem::move ( const QPoint & pnt )   [virtual]

This is an overloaded function.

Moves the item to the point pnt.

void Q3IconViewItem::moveBy ( int dx, int dy )   [virtual]

Moves the item dx pixels in the x-direction and dy pixels in the y-direction.

void Q3IconViewItem::moveBy ( const QPoint & pnt )   [virtual]

This is an overloaded function.

Moves the item by the x, y values in point pnt.

Q3IconViewItem * Q3IconViewItem::nextItem () const

Returns a pointer to the next item, or 0 if this is the last item in the icon view.

To find the first item use Q3IconView::firstItem().

Example:

 Q3IconViewItem *item;
 for (item = iconView->firstItem(); item; item = item->nextItem())
     do_something_with(item);

See also prevItem().

void Q3IconViewItem::paintFocus ( QPainter * p, const QColorGroup & cg )   [virtual protected]

Paints the focus rectangle of the item using the painter p and the color group cg.

void Q3IconViewItem::paintItem ( QPainter * p, const QColorGroup & cg )   [virtual protected]

Paints the item using the painter p and the color group cg. If you want the item to be drawn with a different font or color, reimplement this function, change the values of the color group or the painter's font, and then call the Q3IconViewItem::paintItem() with the changed values.

QPicture * Q3IconViewItem::picture () const   [virtual]

Returns the icon of the icon view item if it is a picture, or 0 if it is a pixmap. In the latter case use pixmap() instead. Normally you set the picture of the item with setPicture(), but sometimes it's inconvenient to call setPicture() for every item. So you can subclass Q3IconViewItem, reimplement this function and return a pointer to the item's picture. If you do this, you must call calcRect() manually each time the size of this picture changes.

See also setPicture().

QPixmap * Q3IconViewItem::pixmap () const   [virtual]

Returns the icon of the icon view item if it is a pixmap, or 0 if it is a picture. In the latter case use picture() instead. Normally you set the pixmap of the item with setPixmap(), but sometimes it's inconvenient to call setPixmap() for every item. So you can subclass Q3IconViewItem, reimplement this function and return a pointer to the item's pixmap. If you do this, you must call calcRect() manually each time the size of this pixmap changes.

See also setPixmap().

QRect Q3IconViewItem::pixmapRect ( bool relative = true ) const

Returns the bounding rectangle of the item's icon.

If relative is true, (the default), the rectangle is relative to the origin of the item's rectangle. If relative is false, the returned rectangle is relative to the origin of the icon view's contents coordinate system.

See also setPixmapRect().

QPoint Q3IconViewItem::pos () const

Returns the position of the item (in contents coordinates).

Q3IconViewItem * Q3IconViewItem::prevItem () const

Returns a pointer to the previous item, or 0 if this is the first item in the icon view.

See also nextItem() and Q3IconView::firstItem().

QRect Q3IconViewItem::rect () const

Returns the bounding rectangle of the item (in contents coordinates).

void Q3IconViewItem::removeRenameBox ()   [virtual protected]

Removes the editbox that is used for in-place renaming.

void Q3IconViewItem::rename ()

Starts in-place renaming of an icon, if allowed.

This function sets up the icon view so that the user can edit the item text, and then returns. When the user is done, setText() will be called and Q3IconView::itemRenamed() will be emitted (unless the user canceled, e.g. by pressing the Escape key).

See also setRenameEnabled().

bool Q3IconViewItem::renameEnabled () const

Returns true if the item can be renamed by the user with in-place renaming; otherwise returns false.

See also setRenameEnabled().

void Q3IconViewItem::repaint ()   [virtual]

Repaints the item.

int Q3IconViewItem::rtti () const   [virtual]

Returns 0.

Make your derived classes return their own values for rtti(), so that you can distinguish between icon view item types. You should use values greater than 1000, preferably a large random number, to allow for extensions to this class.

void Q3IconViewItem::setDragEnabled ( bool allow )   [virtual]

If allow is true, the icon view permits the user to drag the icon view item either to another position within the icon view or to somewhere outside of it. If allow is false, the item cannot be dragged.

See also dragEnabled().

void Q3IconViewItem::setDropEnabled ( bool allow )   [virtual]

If allow is true, the icon view lets the user drop something on this icon view item.

See also dropEnabled().

void Q3IconViewItem::setItemRect ( const QRect & r )   [protected]

Sets the bounding rectangle of the whole item to r. This function is provided for subclasses which reimplement calcRect(), so that they can set the calculated rectangle. Any other use is discouraged.

See also calcRect(), textRect(), setTextRect(), pixmapRect(), and setPixmapRect().

void Q3IconViewItem::setKey ( const QString & k )   [virtual]

Sets k as the sort key of the icon view item. By default text() is used for sorting.

See also key() and compare().

void Q3IconViewItem::setPicture ( const QPicture & icon )   [virtual]

Sets icon as the item's icon in the icon view. This function might be a no-op if you reimplement picture().

See also picture().

void Q3IconViewItem::setPixmap ( const QPixmap & icon )   [virtual]

Sets icon as the item's icon in the icon view. This function might be a no-op if you reimplement pixmap().

See also pixmap().

void Q3IconViewItem::setPixmap ( const QPixmap & icon, bool recalc, bool redraw = true )   [virtual]

This is an overloaded function.

Sets icon as the item's icon in the icon view. If recalc is true, the icon view's layout is recalculated. If redraw is true (the default), the icon view is repainted.

See also pixmap().

void Q3IconViewItem::setPixmapRect ( const QRect & r )   [protected]

Sets the bounding rectangle of the item's icon to r. This function is provided for subclasses which reimplement calcRect(), so that they can set the calculated rectangle. Any other use is discouraged.

See also calcRect(), pixmapRect(), setItemRect(), and setTextRect().

void Q3IconViewItem::setRenameEnabled ( bool allow )   [virtual]

If allow is true, the user can rename the icon view item by clicking on the text (or pressing F2) while the item is selected (in-place renaming). If allow is false, in-place renaming is not possible.

See also renameEnabled().

void Q3IconViewItem::setSelectable ( bool enable )   [virtual]

Sets this item to be selectable if enable is true (the default) or unselectable if enable is false.

The user is unable to select a non-selectable item using either the keyboard or the mouse. (The application programmer can select an item in code regardless of this setting.)

See also isSelectable().

void Q3IconViewItem::setSelected ( bool s, bool cb )   [virtual]

Selects or unselects the item, depending on s; it may also unselect other items, depending on Q3IconView::selectionMode() and cb.

If s is false, the item is unselected.

If s is true and Q3IconView::selectionMode() is Q3IconView::Single, the item is selected and the item previously selected is unselected.

If s is true and Q3IconView::selectionMode() is Q3IconView::Extended, the item is selected. If cb is true, the selection state of the other items is left unchanged. If cb is false (the default) all other items are unselected.

If s is true and Q3IconView::selectionMode() is Q3IconView::Multi, the item is selected.

Note that cb is used only if Q3IconView::selectionMode() is Q3IconView::Extended; cb defaults to false.

All items whose selection status changes repaint themselves.

See also isSelected().

void Q3IconViewItem::setSelected ( bool s )   [virtual]

This is an overloaded function.

This variant is equivalent to calling the other variant with cb set to false.

void Q3IconViewItem::setText ( const QString & text )   [virtual]

Sets text as the text of the icon view item. This function might be a no-op if you reimplement text().

See also text().

void Q3IconViewItem::setText ( const QString & text, bool recalc, bool redraw = true )   [virtual]

This is an overloaded function.

Sets text as the text of the icon view item. If recalc is true, the icon view's layout is recalculated. If redraw is true (the default), the icon view is repainted.

See also text().

void Q3IconViewItem::setTextRect ( const QRect & r )   [protected]

Sets the bounding rectangle of the item's text to r. This function is provided for subclasses which reimplement calcRect(), so that they can set the calculated rectangle. Any other use is discouraged.

See also calcRect(), textRect(), setItemRect(), and setPixmapRect().

QSize Q3IconViewItem::size () const

Returns the size of the item.

QString Q3IconViewItem::text () const   [virtual]

Returns the text of the icon view item. Normally you set the text of the item with setText(), but sometimes it's inconvenient to call setText() for every item; so you can subclass Q3IconViewItem, reimplement this function, and return the text of the item. If you do this, you must call calcRect() manually each time the text (and therefore its size) changes.

See also setText().

QRect Q3IconViewItem::textRect ( bool relative = true ) const

Returns the bounding rectangle of the item's text.

If relative is true, (the default), the returned rectangle is relative to the origin of the item's rectangle. If relative is false, the returned rectangle is relative to the origin of the icon view's contents coordinate system.

See also setTextRect().

int Q3IconViewItem::width () const

Returns the width of the item.

int Q3IconViewItem::x () const

Returns the x-coordinate of the item (in contents coordinates).

int Q3IconViewItem::y () const

Returns the y-coordinate of the item (in contents coordinates).

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 73
  2. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 27
  3. Une nouvelle ère d'IHM 3D pour les automobiles, un concept proposé par Digia et implémenté avec Qt 3
  4. Qt Creator 2.5 est sorti en beta, l'EDI supporte maintenant plus de fonctionnalités de C++11 2
  5. Vingt sociétés montrent leurs décodeurs basés sur Qt au IPTV World Forum, en en exploitant diverses facettes (déclaratif, Web, widgets) 0
  6. PySide devient un add-on Qt et rejoint le Qt Project et le modèle d'open gouvernance 1
  7. Thread travailleur avec Qt en utilisant les signaux et les slots, un article de Christophe Dumez traduit par Thibaut Cuvelier 1
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 102
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 51
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 73
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 27
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 229
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
  7. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 101
Page suivante

Le Qt Labs au hasard

Logo

Chaînes et SIMD, la revanche (de Latin1)

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.5
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web