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  · 

Q3IconView Class Reference
[Qt3Support module]

The Q3IconView class provides an area with movable labelled icons. More...

 #include <Q3IconView>

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.

Inherits Q3ScrollView.


Public Types

enum Arrangement { LeftToRight, TopToBottom }
typedef ComparisonFlags
enum ItemTextPos { Bottom, Right }
enum ResizeMode { Fixed, Adjust }
enum SelectionMode { Single, Multi, Extended, NoSelection }
enum StringComparisonMode { CaseSensitive, ExactMatch, BeginsWith, EndsWith, Contains }

Properties


Public Functions

Q3IconView ( QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0 )
virtual ~Q3IconView ()
Arrangement arrangement () const
bool autoArrange () const
virtual void clear ()
virtual void clearSelection ()
uint count () const
Q3IconViewItem * currentItem () const
void ensureItemVisible ( Q3IconViewItem * item )
Q3IconViewItem * findFirstVisibleItem ( const QRect & r ) const
Q3IconViewItem * findItem ( const QPoint & pos ) const
Q3IconViewItem * findItem ( const QString & text, ComparisonFlags compare = BeginsWith | Qt::CaseSensitive ) const
Q3IconViewItem * findLastVisibleItem ( const QRect & r ) const
Q3IconViewItem * firstItem () const
int gridX () const
int gridY () const
int index ( const Q3IconViewItem * item ) const
virtual void insertItem ( Q3IconViewItem * item, Q3IconViewItem * after = 0L )
virtual void invertSelection ()
bool isRenaming () const
QBrush itemTextBackground () const
ItemTextPos itemTextPos () const
bool itemsMovable () const
Q3IconViewItem * lastItem () const
int maxItemTextLength () const
int maxItemWidth () const
virtual void repaintItem ( Q3IconViewItem * item )
void repaintSelectedItems ()
ResizeMode resizeMode () const
virtual void selectAll ( bool select )
SelectionMode selectionMode () const
virtual void setArrangement ( Arrangement am )
virtual void setAutoArrange ( bool b )
virtual void setCurrentItem ( Q3IconViewItem * item )
virtual void setGridX ( int rx )
virtual void setGridY ( int ry )
virtual void setItemTextBackground ( const QBrush & b )
virtual void setItemTextPos ( ItemTextPos pos )
virtual void setItemsMovable ( bool b )
virtual void setMaxItemTextLength ( int w )
virtual void setMaxItemWidth ( int w )
virtual void setResizeMode ( ResizeMode am )
virtual void setSelected ( Q3IconViewItem * item, bool s, bool cb = false )
virtual void setSelectionMode ( SelectionMode m )
virtual void setShowToolTips ( bool b )
void setSorting ( bool sort, bool ascending = true )
virtual void setSpacing ( int sp )
virtual void setWordWrapIconText ( bool b )
bool showToolTips () const
virtual void sort ( bool ascending = true )
bool sortDirection () const
bool sorting () const
int spacing () const
virtual void takeItem ( Q3IconViewItem * item )
bool wordWrapIconText () const

Reimplemented Public Functions

virtual bool eventFilter ( QObject * o, QEvent * e )
virtual QVariant inputMethodQuery ( Qt::InputMethodQuery query ) const
virtual QSize minimumSizeHint () const
virtual void showEvent ( QShowEvent * )
virtual QSize sizeHint () const
  • 49 public functions inherited from Q3ScrollView
  • 4 public functions inherited from Q3Frame
  • 14 public functions inherited from QFrame
  • 217 public functions inherited from QWidget
  • 29 public functions inherited from QObject
  • 13 public functions inherited from QPaintDevice

Public Slots

virtual void arrangeItemsInGrid ( const QSize & grid, bool update = true )
virtual void arrangeItemsInGrid ( bool update = true )
virtual void setContentsPos ( int x, int y )

Signals

void clicked ( Q3IconViewItem * item )
void clicked ( Q3IconViewItem * item, const QPoint & pos )
void contextMenuRequested ( Q3IconViewItem * item, const QPoint & pos )
void currentChanged ( Q3IconViewItem * item )
void doubleClicked ( Q3IconViewItem * item )
void dropped ( QDropEvent * e, const Q3ValueList<Q3IconDragItem> & lst )
void itemRenamed ( Q3IconViewItem * item, const QString & name )
void itemRenamed ( Q3IconViewItem * item )
void mouseButtonClicked ( int button, Q3IconViewItem * item, const QPoint & pos )
void mouseButtonPressed ( int button, Q3IconViewItem * item, const QPoint & pos )
void moved ()
void onItem ( Q3IconViewItem * item )
void onViewport ()
void pressed ( Q3IconViewItem * item )
void pressed ( Q3IconViewItem * item, const QPoint & pos )
void returnPressed ( Q3IconViewItem * item )
void rightButtonClicked ( Q3IconViewItem * item, const QPoint & pos )
void rightButtonPressed ( Q3IconViewItem * item, const QPoint & pos )
void selectionChanged ()
void selectionChanged ( Q3IconViewItem * item )

Protected Functions

virtual Q3DragObject * dragObject ()
virtual void drawBackground ( QPainter * p, const QRect & r )
virtual void drawRubber ( QPainter * p )
void emitSelectionChanged ( Q3IconViewItem * i = 0 )
virtual void insertInGrid ( Q3IconViewItem * item )
Q3IconViewItem * makeRowLayout ( Q3IconViewItem * begin, int & y, bool & changed )
virtual void startDrag ()

Reimplemented Protected Functions

virtual void changeEvent ( QEvent * ev )
virtual void contentsContextMenuEvent ( QContextMenuEvent * e )
virtual void contentsDragEnterEvent ( QDragEnterEvent * e )
virtual void contentsDragLeaveEvent ( QDragLeaveEvent * e )
virtual void contentsDragMoveEvent ( QDragMoveEvent * e )
virtual void contentsDropEvent ( QDropEvent * e )
virtual void contentsMouseDoubleClickEvent ( QMouseEvent * e )
virtual void contentsMouseMoveEvent ( QMouseEvent * e )
virtual void contentsMousePressEvent ( QMouseEvent * e )
virtual void contentsMouseReleaseEvent ( QMouseEvent * e )
virtual void drawContents ( QPainter * p, int cx, int cy, int cw, int ch )
virtual void enterEvent ( QEvent * e )
virtual void focusInEvent ( QFocusEvent * e )
virtual void focusOutEvent ( QFocusEvent * e )
virtual void keyPressEvent ( QKeyEvent * e )
virtual void resizeEvent ( QResizeEvent * e )
  • 26 protected functions inherited from Q3ScrollView
  • 5 protected functions inherited from Q3Frame
  • 3 protected functions inherited from QFrame
  • 37 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice

Protected Slots

virtual void adjustItems ()
virtual void doAutoScroll ()
virtual void slotUpdate ()
  • 1 protected slot inherited from QWidget

Additional Inherited Members

  • 4 static public members inherited from QWidget
  • 5 static public members inherited from QObject

Detailed Description

The Q3IconView class provides an area with movable labelled icons.

A Q3IconView can display and manage a grid or other 2D layout of labelled icons. Each labelled icon is a Q3IconViewItem. Items (Q3IconViewItems) can be added or deleted at any time; items can be moved within the Q3IconView. Single or multiple items can be selected. Items can be renamed in-place. Q3IconView also supports drag and drop.

Each item contains a label string, a pixmap or picture (the icon itself) and optionally a sort key. The sort key is used for sorting the items and defaults to the label string. The label string can be displayed below or to the right of the icon (see ItemTextPos).

The simplest way to create a Q3IconView is to create a Q3IconView object and create some Q3IconViewItems with the Q3IconView as their parent, set the icon view's geometry and show it. For example:

 Q3IconView *iv = new Q3IconView(this);
 QDir dir(path, "*.xpm");
 for (uint i = 0; i < dir.count(); i++) {
     (void) new Q3IconViewItem(iv, dir[i], QPixmap(path + dir[i]));
 }
 iv->resize(600, 400);
 iv->show();

The Q3IconViewItem call passes a pointer to the Q3IconView we wish to populate, along with the label text and a QPixmap.

When an item is inserted the Q3IconView allocates a position for it. Existing items are rearranged if autoArrange() is true. The default arrangement is LeftToRight -- the Q3IconView fills up the left-most column from top to bottom, then moves one column right and fills that from top to bottom and so on. The arrangement can be modified with any of the following approaches:

  • Call setArrangement(), e.g. with TopToBottom which will fill the top-most row from left to right, then moves one row down and fills that row from left to right and so on.
  • Construct each Q3IconViewItem using a constructor which allows you to specify which item the new one is to follow.
  • Call setSorting() or sort() to sort the items.

The spacing between items is set with setSpacing(). Items can be laid out using a fixed grid using setGridX() and setGridY(); by default the Q3IconView calculates a grid dynamically. The position of items' label text is set with setItemTextPos(). The text's background can be set with setItemTextBackground(). The maximum width of an item and of its text are set with setMaxItemWidth() and setMaxItemTextLength(). The label text will be word-wrapped if it is too long; this is controlled by setWordWrapIconText(). If the label text is truncated, the user can still see the entire text in a tool tip if they hover the mouse over the item. This is controlled with setShowToolTips().

Items which are selectable may be selected depending on the SelectionMode; the default is Single. Because Q3IconView offers multiple selection it must display keyboard focus and selection state separately. Therefore there are functions to set the selection state of an item (setSelected()) and to select which item displays keyboard focus (setCurrentItem()). When multiple items may be selected the icon view provides a rubberband, too.

When in-place renaming is enabled (it is disabled by default), the user may change the item's label. They do this by selecting the item (single clicking it or navigating to it with the arrow keys), then single clicking it (or pressing F2), and entering their text. If no key has been set with Q3IconViewItem::setKey() the new text will also serve as the key. (See Q3IconViewItem::setRenameEnabled().)

You can control whether users can move items themselves with setItemsMovable().

Because the internal structure used to store the icon view items is linear, no iterator class is needed to iterate over all the items. Instead we iterate by getting the first item from the icon view and then each subsequent (Q3IconViewItem::nextItem()) from each item in turn:

 for (Q3IconViewItem *item = iv->firstItem(); item; item = item->nextItem())
     do_something(item);

Q3IconView also provides currentItem(). You can search for an item using findItem() (searching by position or for label text) and with findFirstVisibleItem() and findLastVisibleItem(). The number of items is returned by count(). An item can be removed from an icon view using takeItem(); to delete an item use delete. All the items can be deleted with clear().

The Q3IconView emits a wide range of useful signals, including selectionChanged(), currentChanged(), clicked(), moved() and itemRenamed().

Drag and Drop

Q3IconView supports the drag and drop of items within the Q3IconView itself. It also supports the drag and drop of items out of or into the Q3IconView and drag and drop onto items themselves. The drag and drop of items outside the Q3IconView can be achieved in a simple way with basic functionality, or in a more sophisticated way which provides more power and control.

The simple approach to dragging items out of the icon view is to subclass Q3IconView and reimplement Q3IconView::dragObject().

 Q3DragObject *MyIconView::dragObject()
 {
     return new Q3TextDrag(currentItem()->text(), this);
 }

In this example we create a Q3TextDrag object, (derived from Q3DragObject), containing the item's label and return it as the drag object. We could just as easily have created a Q3ImageDrag from the item's pixmap and returned that instead.

Q3IconViews and their Q3IconViewItems can also be the targets of drag and drops. To make the Q3IconView itself able to accept drops connect to the dropped() signal. When a drop occurs this signal will be emitted with a QDragEvent and a QLinkedList of Q3IconDragItems. To make a Q3IconViewItem into a drop target subclass Q3IconViewItem and reimplement Q3IconViewItem::acceptDrop() and Q3IconViewItem::dropped().

 bool MyIconViewItem::acceptDrop(const QMimeSource *mime) const
 {
     if (mime->provides("text/plain"))
         return true;
     return false;
 }

 void MyIconViewItem::dropped(QDropEvent *evt, const Q3ValueList<Q3IconDragItem>&)
 {
     QString label;
     if (Q3TextDrag::decode(evt, label))
         setText(label);
 }

If you want to use extended drag-and-drop or have drag shapes drawn you must take a more sophisticated approach.

The first part is starting drags -- you should use a Q3IconDrag (or a class derived from it) for the drag object. In dragObject() create the drag object, populate it with Q3IconDragItems and return it. Normally such a drag should offer each selected item's data. So in dragObject() you should iterate over all the items, and create a Q3IconDragItem for each selected item, and append these items with Q3IconDrag::append() to the Q3IconDrag object. You can use Q3IconDragItem::setData() to set the data of each item that should be dragged. If you want to offer the data in additional mime-types, it's best to use a class derived from Q3IconDrag, which implements additional encoding and decoding functions.

When a drag enters the icon view, there is little to do. Simply connect to the dropped() signal and reimplement Q3IconViewItem::acceptDrop() and Q3IconViewItem::dropped(). If you've used a Q3IconDrag (or a subclass of it) the second argument to the dropped signal contains a QLinkedList of Q3IconDragItems -- you can access their data by calling Q3IconDragItem::data() on each one.

For an example implementation of complex drag-and-drop look at the fileiconview example (qt/examples/fileiconview).

See also Q3IconViewItem::setDragEnabled(), Q3IconViewItem::setDropEnabled(), Q3IconViewItem::acceptDrop(), and Q3IconViewItem::dropped().


Member Type Documentation

enum Q3IconView::Arrangement

This enum type determines in which direction the items flow when the view runs out of space.

ConstantValueDescription
Q3IconView::LeftToRight0Items which don't fit into the view go further down (you get a vertical scroll bar)
Q3IconView::TopToBottom1Items which don't fit into the view go further right (you get a horizontal scroll bar)

typedef Q3IconView::ComparisonFlags

This typedef is used in Q3IconView's API for values that are OR'd combinations of StringComparisonMode values.

See also StringComparisonMode.

enum Q3IconView::ItemTextPos

This enum type specifies the position of the item text in relation to the icon.

ConstantValueDescription
Q3IconView::Bottom0The text is drawn below the icon.
Q3IconView::Right1The text is drawn to the right of the icon.

enum Q3IconView::ResizeMode

This enum type is used to tell Q3IconView how it should treat the positions of its icons when the widget is resized. The modes are:

ConstantValueDescription
Q3IconView::Fixed0The icons' positions are not changed.
Q3IconView::Adjust1The icons' positions are adjusted to be within the new geometry, if possible.

enum Q3IconView::SelectionMode

This enumerated type is used by Q3IconView to indicate how it reacts to selection by the user. It has four values:

ConstantValueDescription
Q3IconView::Single0When the user selects an item, any already-selected item becomes unselected and the user cannot unselect the selected item. This means that the user can never clear the selection. (The application programmer can, using Q3IconView::clearSelection().)
Q3IconView::Multi1When the user selects an item, e.g. by navigating to it with the keyboard arrow keys or by clicking it, the selection status of that item is toggled and the other items are left alone.
Q3IconView::Extended2When the user selects an item the selection is cleared and the new item selected. However, if the user presses the Ctrl key when clicking on an item, the clicked item gets toggled and all other items are left untouched. If the user presses the Shift key while clicking on an item, all items between the current item and the clicked item get selected or unselected, depending on the state of the clicked item. Also, multiple items can be selected by dragging the mouse while the left mouse button stays pressed.
Q3IconView::NoSelection3Items cannot be selected.

To summarize: Single is a real single-selection icon view; Multi a real multi-selection icon view; Extended is an icon view in which users can select multiple items but usually want to select either just one or a range of contiguous items; and NoSelection mode is for an icon view where the user can look but not touch.

enum Q3IconView::StringComparisonMode

This enum type is used to set the string comparison mode when searching for an item. We'll refer to the string being searched as the 'target' string.

ConstantValueDescription
Q3IconView::CaseSensitive0x00001The strings must match case sensitively.
Q3IconView::ExactMatch0x00010The target and search strings must match exactly.
Q3IconView::BeginsWith0x00002The target string begins with the search string.
Q3IconView::EndsWith0x00004The target string ends with the search string.
Q3IconView::Contains0x00008The target string contains the search string.

If you OR these flags together (excluding CaseSensitive), the search criteria be applied in the following order: ExactMatch, BeginsWith, EndsWith, Contains.

Matching is case-insensitive unless CaseSensitive is set. CaseSensitive can be OR-ed with any combination of the other flags.

See also ComparisonFlags.


Property Documentation

arrangement : Arrangement

This property holds the arrangement mode of the icon view.

This can be LeftToRight or TopToBottom. The default is LeftToRight.

Access functions:

Arrangement arrangement () const
virtual void setArrangement ( Arrangement am )

autoArrange : bool

This property holds whether the icon view rearranges its items when a new item is inserted.

The default is true.

Note that if the icon view is not visible at the time of insertion, Q3IconView defers all position-related work until it is shown and then calls arrangeItemsInGrid().

Access functions:

bool autoArrange () const
virtual void setAutoArrange ( bool b )

count : const uint

This property holds the number of items in the icon view.

Access functions:

uint count () const

gridX : int

This property holds the horizontal grid of the icon view.

If the value is -1, (the default), Q3IconView computes suitable column widths based on the icon view's contents.

Note that setting a grid width overrides setMaxItemWidth().

Access functions:

int gridX () const
virtual void setGridX ( int rx )

gridY : int

This property holds the vertical grid of the icon view.

If the value is -1, (the default), Q3IconView computes suitable column heights based on the icon view's contents.

Access functions:

int gridY () const
virtual void setGridY ( int ry )

itemTextBackground : QBrush

This property holds the brush to use when drawing the background of an item's text.

By default this brush is set to Qt::NoBrush, meaning that only the normal icon view background is used.

Access functions:

QBrush itemTextBackground () const
virtual void setItemTextBackground ( const QBrush & b )

itemTextPos : ItemTextPos

This property holds the position where the text of each item is drawn.

Valid values are Bottom or Right. The default is Bottom.

Access functions:

ItemTextPos itemTextPos () const
virtual void setItemTextPos ( ItemTextPos pos )

itemsMovable : bool

This property holds whether the user is allowed to move items around in the icon view.

The default is true.

Access functions:

bool itemsMovable () const
virtual void setItemsMovable ( bool b )

maxItemTextLength : int

This property holds the maximum length (in characters) that an item's text may have.

The default is 255 characters.

Access functions:

int maxItemTextLength () const
virtual void setMaxItemTextLength ( int w )

maxItemWidth : int

This property holds the maximum width that an item may have.

The default is 100 pixels.

Note that if the gridX() value is set Q3IconView will ignore this property.

Access functions:

int maxItemWidth () const
virtual void setMaxItemWidth ( int w )

resizeMode : ResizeMode

This property holds the resize mode of the icon view.

This can be Fixed or Adjust. The default is Fixed. See ResizeMode.

Access functions:

ResizeMode resizeMode () const
virtual void setResizeMode ( ResizeMode am )

selectionMode : SelectionMode

This property holds the selection mode of the icon view.

This can be Single (the default), Extended, Multi or NoSelection.

Access functions:

SelectionMode selectionMode () const
virtual void setSelectionMode ( SelectionMode m )

showToolTips : bool

This property holds whether the icon view will display a tool tip with the complete text for any truncated item text.

The default is true. Note that this has no effect if setWordWrapIconText() is true, as it is by default.

Access functions:

bool showToolTips () const
virtual void setShowToolTips ( bool b )

sortDirection : const bool

This property holds whether the sort direction for inserting new items is ascending;.

The default is true (i.e. ascending). This sort direction is only meaningful if both sorting() and autoArrange() are true.

To set the sort direction, use setSorting()

Access functions:

bool sortDirection () const

sorting : const bool

This property holds whether the icon view sorts on insertion.

The default is false, i.e. no sorting on insertion.

To set the sorting, use setSorting().

Access functions:

bool sorting () const

spacing : int

This property holds the space in pixels between icon view items.

The default is 5 pixels.

Negative values for spacing are illegal.

Access functions:

int spacing () const
virtual void setSpacing ( int sp )

wordWrapIconText : bool

This property holds whether the item text will be word-wrapped if it is too long.

The default is true.

If this property is false, icon text that is too long is truncated, and an ellipsis (...) appended to indicate that truncation has occurred. The full text can still be seen by the user if they hover the mouse because the full text is shown in a tooltip; see setShowToolTips().

Access functions:

bool wordWrapIconText () const
virtual void setWordWrapIconText ( bool b )

Member Function Documentation

Q3IconView::Q3IconView ( QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0 )

Constructs an empty icon view called name, with parent parent and using the widget flags f.

Q3IconView::~Q3IconView ()   [virtual]

Destroys the icon view and deletes all items.

void Q3IconView::adjustItems ()   [virtual protected slot]

Adjusts the positions of the items to the geometry of the icon view.

void Q3IconView::arrangeItemsInGrid ( const QSize & grid, bool update = true )   [virtual slot]

This variant uses grid instead of (gridX(), gridY()). If grid is invalid (see QSize::isValid()), arrangeItemsInGrid() calculates a valid grid itself and uses that.

If update is true (the default) the viewport is repainted.

void Q3IconView::arrangeItemsInGrid ( bool update = true )   [virtual slot]

This is an overloaded function.

Arranges all the items in the grid specified by gridX() and gridY().

Even if sorting() is enabled, the items are not sorted by this function. If you want to sort or rearrange the items, use iconview->sort(iconview->sortDirection()).

If update is true (the default), the viewport is repainted as well.

See also Q3IconView::setGridX(), Q3IconView::setGridY(), and Q3IconView::sort().

void Q3IconView::changeEvent ( QEvent * ev )   [virtual protected]

Reimplemented from QWidget::changeEvent().

void Q3IconView::clear ()   [virtual]

Clears the icon view. All items are deleted.

void Q3IconView::clearSelection ()   [virtual]

Unselects all the items.

void Q3IconView::clicked ( Q3IconViewItem * item )   [signal]

This signal is emitted when the user clicks any mouse button. If item is non-null, the cursor is on item. If item is null, the mouse cursor isn't on any item.

See also mouseButtonClicked(), rightButtonClicked(), and pressed().

void Q3IconView::clicked ( Q3IconViewItem * item, const QPoint & pos )   [signal]

This is an overloaded function.

This signal is emitted when the user clicks any mouse button on an icon view item. item is a pointer to the item that has been clicked.

pos is the position of the mouse cursor in the global coordinate system (QMouseEvent::globalPos()). (If the click's press and release differ by a pixel or two, pos is the position at release time.)

See also mouseButtonClicked(), rightButtonClicked(), and pressed().

void Q3IconView::contentsContextMenuEvent ( QContextMenuEvent * e )   [virtual protected]

Reimplemented from Q3ScrollView::contentsContextMenuEvent().

void Q3IconView::contentsDragEnterEvent ( QDragEnterEvent * e )   [virtual protected]

Reimplemented from Q3ScrollView::contentsDragEnterEvent().

void Q3IconView::contentsDragLeaveEvent ( QDragLeaveEvent * e )   [virtual protected]

Reimplemented from Q3ScrollView::contentsDragLeaveEvent().

void Q3IconView::contentsDragMoveEvent ( QDragMoveEvent * e )   [virtual protected]

Reimplemented from Q3ScrollView::contentsDragMoveEvent().

void Q3IconView::contentsDropEvent ( QDropEvent * e )   [virtual protected]

Reimplemented from Q3ScrollView::contentsDropEvent().

void Q3IconView::contentsMouseDoubleClickEvent ( QMouseEvent * e )   [virtual protected]

Reimplemented from Q3ScrollView::contentsMouseDoubleClickEvent().

void Q3IconView::contentsMouseMoveEvent ( QMouseEvent * e )   [virtual protected]

Reimplemented from Q3ScrollView::contentsMouseMoveEvent().

void Q3IconView::contentsMousePressEvent ( QMouseEvent * e )   [virtual protected]

Reimplemented from Q3ScrollView::contentsMousePressEvent().

void Q3IconView::contentsMouseReleaseEvent ( QMouseEvent * e )   [virtual protected]

Reimplemented from Q3ScrollView::contentsMouseReleaseEvent().

void Q3IconView::contextMenuRequested ( Q3IconViewItem * item, const QPoint & pos )   [signal]

This signal is emitted when the user invokes a context menu with the right mouse button or with special system keys, with item being the item under the mouse cursor or the current item, respectively.

pos is the position for the context menu in the global coordinate system.

void Q3IconView::currentChanged ( Q3IconViewItem * item )   [signal]

This signal is emitted when a new item becomes current. item is the new current item (or 0 if no item is now current).

See also currentItem().

Q3IconViewItem * Q3IconView::currentItem () const

Returns a pointer to the current item of the icon view, or 0 if no item is current.

See also setCurrentItem(), firstItem(), and lastItem().

void Q3IconView::doAutoScroll ()   [virtual protected slot]

Performs autoscrolling when selecting multiple icons with the rubber band.

void Q3IconView::doubleClicked ( Q3IconViewItem * item )   [signal]

This signal is emitted when the user double-clicks on item.

Q3DragObject * Q3IconView::dragObject ()   [virtual protected]

Returns the Q3DragObject that should be used for drag-and-drop. This function is called by the icon view when starting a drag to get the dragobject that should be used for the drag. Subclasses may reimplement this.

See also Q3IconDrag.

void Q3IconView::drawBackground ( QPainter * p, const QRect & r )   [virtual protected]

This function is called to draw the rectangle r of the background using the painter p.

The default implementation fills r with the viewport's backgroundBrush(). Subclasses can reimplement this to draw custom backgrounds.

See also drawContents().

void Q3IconView::drawContents ( QPainter * p, int cx, int cy, int cw, int ch )   [virtual protected]

Reimplemented from Q3ScrollView::drawContents().

void Q3IconView::drawRubber ( QPainter * p )   [virtual protected]

Draws the rubber band using the painter p.

void Q3IconView::dropped ( QDropEvent * e, const Q3ValueList<Q3IconDragItem> & lst )   [signal]

This signal is emitted when a drop event occurs in the viewport (but not on any icon) which the icon view itself can't handle.

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 using Q3IconDragItem::data() on each item. If the lst is empty, i.e. the drag was not a Q3IconDrag, you have to decode the data in e and work with that.

Note Q3IconViewItems may be drop targets; if a drop event occurs on an item the item handles the drop.

void Q3IconView::emitSelectionChanged ( Q3IconViewItem * i = 0 )   [protected]

Emits a signal to indicate selection changes. i is the Q3IconViewItem that was selected or de-selected.

You should never need to call this function.

void Q3IconView::ensureItemVisible ( Q3IconViewItem * item )

Makes sure that item is entirely visible. If necessary, ensureItemVisible() scrolls the icon view.

See also ensureVisible().

void Q3IconView::enterEvent ( QEvent * e )   [virtual protected]

Reimplemented from QWidget::enterEvent().

bool Q3IconView::eventFilter ( QObject * o, QEvent * e )   [virtual]

Reimplemented from QObject::eventFilter().

Q3IconViewItem * Q3IconView::findFirstVisibleItem ( const QRect & r ) const

Finds the first item whose bounding rectangle overlaps r and returns a pointer to that item. r is given in content coordinates. Returns 0 if no item overlaps r.

If you want to find all items that touch r, you will need to use this function and nextItem() in a loop ending at findLastVisibleItem() and test Q3IconViewItem::rect() for each of these items.

See also findLastVisibleItem() and Q3IconViewItem::rect().

Q3IconViewItem * Q3IconView::findItem ( const QPoint & pos ) const

Returns a pointer to the item that contains point pos, which is given in contents coordinates, or 0 if no item contains point pos.

Q3IconViewItem * Q3IconView::findItem ( const QString & text, ComparisonFlags compare = BeginsWith | Qt::CaseSensitive ) const

This is an overloaded function.

Returns a pointer to the first item whose text begins with text, or 0 if no such item could be found. Use the compare flag to control the comparison behavior.

Q3IconViewItem * Q3IconView::findLastVisibleItem ( const QRect & r ) const

Finds the last item whose bounding rectangle overlaps r and returns a pointer to that item. r is given in content coordinates. Returns 0 if no item overlaps r.

See also findFirstVisibleItem().

Q3IconViewItem * Q3IconView::firstItem () const

Returns a pointer to the first item of the icon view, or 0 if there are no items in the icon view.

See also lastItem() and currentItem().

void Q3IconView::focusInEvent ( QFocusEvent * e )   [virtual protected]

Reimplemented from QWidget::focusInEvent().

void Q3IconView::focusOutEvent ( QFocusEvent * e )   [virtual protected]

Reimplemented from QWidget::focusOutEvent().

int Q3IconView::index ( const Q3IconViewItem * item ) const

Returns the index of item, or -1 if item doesn't exist in this icon view.

QVariant Q3IconView::inputMethodQuery ( Qt::InputMethodQuery query ) const   [virtual]

Reimplemented from QWidget::inputMethodQuery().

void Q3IconView::insertInGrid ( Q3IconViewItem * item )   [virtual protected]

Inserts the Q3IconViewItem item in the icon view's grid. You should never need to call this function. Instead, insert Q3IconViewItems by creating them with a pointer to the Q3IconView that they are to be inserted into.

void Q3IconView::insertItem ( Q3IconViewItem * item, Q3IconViewItem * after = 0L )   [virtual]

Inserts the icon view item item after after. If after is 0, item is appended after the last item.

You should never need to call this function. Instead create Q3IconViewItem's and associate them with your icon view like this:

 (void) new Q3IconViewItem(myIconview, "The text of the item", aPixmap);

void Q3IconView::invertSelection ()   [virtual]

Inverts the selection. Works only in Multi and Extended selection mode.

bool Q3IconView::isRenaming () const

Returns true if an iconview item is being renamed; otherwise returns false.

void Q3IconView::itemRenamed ( Q3IconViewItem * item, const QString & name )   [signal]

This signal is emitted when item has been renamed to name, usually by in-place renaming.

See also Q3IconViewItem::setRenameEnabled() and Q3IconViewItem::rename().

void Q3IconView::itemRenamed ( Q3IconViewItem * item )   [signal]

This is an overloaded function.

This signal is emitted when item has been renamed, usually by in-place renaming.

See also Q3IconViewItem::setRenameEnabled() and Q3IconViewItem::rename().

void Q3IconView::keyPressEvent ( QKeyEvent * e )   [virtual protected]

Reimplemented from QWidget::keyPressEvent().

Q3IconViewItem * Q3IconView::lastItem () const

Returns a pointer to the last item of the icon view, or 0 if there are no items in the icon view.

See also firstItem() and currentItem().

Q3IconViewItem * Q3IconView::makeRowLayout ( Q3IconViewItem * begin, int & y, bool & changed )   [protected]

Lays out a row of icons (if Arrangement == TopToBottom this is a column). Starts laying out with the item begin. y is the starting coordinate. Returns the last item of the row (column) and sets the new starting coordinate to y. The changed parameter is used internally.

Warning: This function may be made private in a future version of Qt. We do not recommend calling it.

QSize Q3IconView::minimumSizeHint () const   [virtual]

Reimplemented from QWidget::minimumSizeHint().

void Q3IconView::mouseButtonClicked ( int button, Q3IconViewItem * item, const QPoint & pos )   [signal]

This signal is emitted when the user clicks mouse button button. If item is non-null, the cursor is on item. If item is null, the mouse cursor isn't on any item.

pos is the position of the mouse cursor in the global coordinate system (QMouseEvent::globalPos()). (If the click's press and release differ by a pixel or two, pos is the position at release time.)

See also mouseButtonPressed(), rightButtonClicked(), and clicked().

void Q3IconView::mouseButtonPressed ( int button, Q3IconViewItem * item, const QPoint & pos )   [signal]

This signal is emitted when the user presses mouse button button. If item is non-null, the cursor is on item. If item is null, the mouse cursor isn't on any item.

pos is the position of the mouse cursor in the global coordinate system (QMouseEvent::globalPos()).

See also rightButtonClicked(), mouseButtonClicked(), and pressed().

void Q3IconView::moved ()   [signal]

This signal is emitted after successfully dropping one (or more) items of the icon view. If the items should be removed, it's best to do so in a slot connected to this signal.

void Q3IconView::onItem ( Q3IconViewItem * item )   [signal]

This signal is emitted when the user moves the mouse cursor onto an item, similar to the QWidget::enterEvent() function.

void Q3IconView::onViewport ()   [signal]

This signal is emitted when the user moves the mouse cursor from an item to an empty part of the icon view.

See also onItem().

void Q3IconView::pressed ( Q3IconViewItem * item )   [signal]

This signal is emitted when the user presses any mouse button. If item is non-null, the cursor is on item. If item is null, the mouse cursor isn't on any item.

See also mouseButtonPressed(), rightButtonPressed(), and clicked().

void Q3IconView::pressed ( Q3IconViewItem * item, const QPoint & pos )   [signal]

This is an overloaded function.

This signal is emitted when the user presses any mouse button. If item is non-null, the cursor is on item. If item is null, the mouse cursor isn't on any item.

pos is the position of the mouse cursor in the global coordinate system (QMouseEvent::globalPos()). (If the click's press and release differ by a pixel or two, pos is the position at release time.)

See also mouseButtonPressed(), rightButtonPressed(), and clicked().

void Q3IconView::repaintItem ( Q3IconViewItem * item )   [virtual]

Repaints the item.

void Q3IconView::repaintSelectedItems ()

Repaints the selected items.

void Q3IconView::resizeEvent ( QResizeEvent * e )   [virtual protected]

Reimplemented from QWidget::resizeEvent().

void Q3IconView::returnPressed ( Q3IconViewItem * item )   [signal]

This signal is emitted if the user presses the Return or Enter key. item is the currentItem() at the time of the keypress.

void Q3IconView::rightButtonClicked ( Q3IconViewItem * item, const QPoint & pos )   [signal]

This signal is emitted when the user clicks the right mouse button. If item is non-null, the cursor is on item. If item is null, the mouse cursor isn't on any item.

pos is the position of the mouse cursor in the global coordinate system (QMouseEvent::globalPos()). (If the click's press and release differ by a pixel or two, pos is the position at release time.)

See also rightButtonPressed(), mouseButtonClicked(), and clicked().

void Q3IconView::rightButtonPressed ( Q3IconViewItem * item, const QPoint & pos )   [signal]

This signal is emitted when the user presses the right mouse button. If item is non-null, the cursor is on item. If item is null, the mouse cursor isn't on any item.

pos is the position of the mouse cursor in the global coordinate system (QMouseEvent::globalPos()).

void Q3IconView::selectAll ( bool select )   [virtual]

In Multi and Extended modes, this function sets all items to be selected if select is true, and to be unselected if select is false.

In Single and NoSelection modes, this function only changes the selection status of currentItem().

void Q3IconView::selectionChanged ()   [signal]

This signal is emitted when the selection has been changed. It's emitted in each selection mode.

void Q3IconView::selectionChanged ( Q3IconViewItem * item )   [signal]

This is an overloaded function.

This signal is emitted when the selection changes. item is the newly selected item. This signal is emitted only in single selection mode.

void Q3IconView::setContentsPos ( int x, int y )   [virtual slot]

Reimplemented from Q3ScrollView::setContentsPos().

void Q3IconView::setCurrentItem ( Q3IconViewItem * item )   [virtual]

Makes item the new current item of the icon view.

See also currentItem().

void Q3IconView::setSelected ( Q3IconViewItem * item, bool s, bool cb = false )   [virtual]

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

If s is false, item is unselected.

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

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

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

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

All items whose selection status is changed repaint themselves.

void Q3IconView::setSorting ( bool sort, bool ascending = true )

If sort is true, this function sets the icon view to sort items when a new item is inserted. If sort is false, the icon view will not be sorted.

Note that autoArrange() must be true for sorting to take place.

If ascending is true (the default), items are sorted in ascending order. If ascending is false, items are sorted in descending order.

Q3IconViewItem::compare() is used to compare pairs of items. The sorting is based on the items' keys; these default to the items' text unless specifically set to something else.

See also sorting(), Q3IconView::setAutoArrange(), Q3IconView::autoArrange(), sortDirection(), sort(), and Q3IconViewItem::setKey().

void Q3IconView::showEvent ( QShowEvent * )   [virtual]

Reimplemented from QWidget::showEvent().

QSize Q3IconView::sizeHint () const   [virtual]

Reimplemented from QWidget::sizeHint().

void Q3IconView::slotUpdate ()   [virtual protected slot]

This slot is used for a slightly-delayed update.

The icon view is not redrawn immediately after inserting a new item but after a very small delay using a QTimer. This means that when many items are inserted in a loop the icon view is probably redrawn only once at the end of the loop. This makes the insertions both flicker-free and faster.

void Q3IconView::sort ( bool ascending = true )   [virtual]

Sorts and rearranges all the items in the icon view. If ascending is true, the items are sorted in increasing order, otherwise they are sorted in decreasing order.

Q3IconViewItem::compare() is used to compare pairs of items. The sorting is based on the items' keys; these default to the items' text unless specifically set to something else.

Note that this function sets the sort order to ascending.

See also Q3IconViewItem::key(), Q3IconViewItem::setKey(), Q3IconViewItem::compare(), Q3IconView::setSorting(), and Q3IconView::sortDirection().

void Q3IconView::startDrag ()   [virtual protected]

Starts a drag.

void Q3IconView::takeItem ( Q3IconViewItem * item )   [virtual]

Takes the icon view item item out of the icon view and causes an update of the screen display. The item is not deleted. You should normally not need to call this function because Q3IconViewItem::~Q3IconViewItem() calls it. The normal way to delete an item is to delete it.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 44
  4. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 6
  7. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
Page suivante

Le Qt Developer Network au hasard

Logo

Les bases

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. 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.6
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