
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQ3IconView class provides an area with movable labelled icons.More...
| Header: | #include <Q3IconView> |
| Inherits: | Q3ScrollView |
| 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 } |
|
|
| 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 |
| 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 |
| virtual void | arrangeItemsInGrid(const QSize & grid, bool update = true) |
| virtual void | arrangeItemsInGrid(bool update = true) |
| virtual void | setContentsPos(int x, int y) |
| 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) |
| 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() |
| 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) |
| virtual void | adjustItems() |
| virtual void | doAutoScroll() |
| virtual void | slotUpdate() |
TheQ3IconView class provides an area with movable labelled icons.
AQ3IconView can display and manage a grid or other 2D layout of labelled icons. Each labelled icon is aQ3IconViewItem. Items (Q3IconViewItems) can be added or deleted at any time; items can be moved within theQ3IconView. Single or multiple items can be selected. Items can be renamed in-place.Q3IconView also supportsdrag 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 (seeItemTextPos).
The simplest way to create aQ3IconView is to create aQ3IconView object and create some Q3IconViewItems with theQ3IconView as their parent, set the icon view's geometry and show it. For example:
Q3IconView*iv=newQ3IconView(this);QDir dir(path,"*.xpm");for (uint i=0; i< dir.count(); i++) { (void)newQ3IconViewItem(iv, dir[i],QPixmap(path+ dir[i]));}iv->resize(600,400);iv->show();
TheQ3IconViewItem call passes a pointer to theQ3IconView we wish to populate, along with the label text and aQPixmap.
When an item is inserted theQ3IconView allocates a position for it. Existing items are rearranged ifautoArrange() is true. The default arrangement isLeftToRight -- theQ3IconView fills up theleft-most column from top to bottom, then moves one columnright and fills that from top to bottom and so on. The arrangement can be modified with any of the following approaches:
The spacing between items is set withsetSpacing(). Items can be laid out using a fixed grid usingsetGridX() andsetGridY(); by default theQ3IconView calculates a grid dynamically. The position of items' label text is set withsetItemTextPos(). The text's background can be set withsetItemTextBackground(). The maximum width of an item and of its text are set withsetMaxItemWidth() andsetMaxItemTextLength(). The label text will be word-wrapped if it is too long; this is controlled bysetWordWrapIconText(). 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 withsetShowToolTips().
Items which areselectable may be selected depending on theSelectionMode; the default isSingle. BecauseQ3IconView 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 withQ3IconViewItem::setKey() the new text will also serve as the key. (SeeQ3IconViewItem::setRenameEnabled().)
You can control whether users can move items themselves withsetItemsMovable().
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 theicon view and then each subsequent (Q3IconViewItem::nextItem()) from eachitem in turn:
for (Q3IconViewItem*item= iv->firstItem(); item; item= item->nextItem()) do_something(item);
Q3IconView also providescurrentItem(). You can search for an item usingfindItem() (searching by position or for label text) and withfindFirstVisibleItem() andfindLastVisibleItem(). The number of items is returned bycount(). An item can be removed from an icon view usingtakeItem(); to delete an item usedelete. All the items can be deleted withclear().
TheQ3IconView emits a wide range of useful signals, includingselectionChanged(),currentChanged(),clicked(),moved() anditemRenamed().
Q3IconView supports the drag and drop of items within theQ3IconView itself. It also supports the drag and drop of items out of or into theQ3IconView and drag and drop onto items themselves. The drag and drop of items outside theQ3IconView 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 subclassQ3IconView and reimplementQ3IconView::dragObject().
Q3DragObject*MyIconView::dragObject(){returnnewQ3TextDrag(currentItem()->text(),this);}
In this example we create aQ3TextDrag object, (derived fromQ3DragObject), containing the item's label and return it as the drag object. We could just as easily have created aQ3ImageDrag from the item's pixmap and returned that instead.
Q3IconViews and their Q3IconViewItems can also be the targets of drag and drops. To make theQ3IconView itself able to accept drops connect to thedropped() signal. When a drop occurs this signal will be emitted with a QDragEvent and aQLinkedList of Q3IconDragItems. To make aQ3IconViewItem into a drop target subclassQ3IconViewItem and reimplementQ3IconViewItem::acceptDrop() andQ3IconViewItem::dropped().
bool MyIconViewItem::acceptDrop(constQMimeSource*mime)const{if (mime->provides("text/plain"))returntrue;returnfalse;}void MyIconViewItem::dropped(QDropEvent*evt,constQ3ValueList<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 aQ3IconDrag (or a class derived from it) for the drag object. IndragObject() create the drag object, populate it with Q3IconDragItems and return it. Normally such a drag should offer each selected item's data. So indragObject() you should iterate over all the items, and create aQ3IconDragItem for each selected item, and append these items withQ3IconDrag::append() to theQ3IconDrag object. You can useQ3IconDragItem::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 fromQ3IconDrag, which implements additional encoding and decoding functions.
When a drag enters the icon view, there is little to do. Simply connect to thedropped() signal and reimplementQ3IconViewItem::acceptDrop() andQ3IconViewItem::dropped(). If you've used aQ3IconDrag (or a subclass of it) the second argument to the dropped signal contains aQLinkedList of Q3IconDragItems -- you can access their data by callingQ3IconDragItem::data() on each one.
For an example implementation of complex drag-and-drop look at the fileiconview example (qt/examples/fileiconview).
See alsoQ3IconViewItem::setDragEnabled(),Q3IconViewItem::setDropEnabled(),Q3IconViewItem::acceptDrop(), andQ3IconViewItem::dropped().
This enum type determines in which direction the items flow when the view runs out of space.
| Constant | Value | Description |
|---|---|---|
Q3IconView::LeftToRight | 0 | Items which don't fit into the view go further down (you get a vertical scroll bar) |
Q3IconView::TopToBottom | 1 | Items which don't fit into the view go further right (you get a horizontal scroll bar) |
This typedef is used inQ3IconView's API for values that are OR'd combinations ofStringComparisonMode values.
See alsoStringComparisonMode.
This enum type specifies the position of the item text in relation to the icon.
| Constant | Value | Description |
|---|---|---|
Q3IconView::Bottom | 0 | The text is drawn below the icon. |
Q3IconView::Right | 1 | The text is drawn to the right of the icon. |
This enum type is used to tellQ3IconView how it should treat the positions of its icons when the widget is resized. The modes are:
| Constant | Value | Description |
|---|---|---|
Q3IconView::Fixed | 0 | The icons' positions are not changed. |
Q3IconView::Adjust | 1 | The icons' positions are adjusted to be within the new geometry, if possible. |
This enumerated type is used byQ3IconView to indicate how it reacts to selection by the user. It has four values:
| Constant | Value | Description |
|---|---|---|
Q3IconView::Single | 0 | When 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, usingQ3IconView::clearSelection().) |
Q3IconView::Multi | 1 | When 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::Extended | 2 | When 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::NoSelection | 3 | Items 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; andNoSelection mode is for an icon view where the user can look but not touch.
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.
| Constant | Value | Description |
|---|---|---|
Q3IconView::CaseSensitive | 0x00001 | The strings must match case sensitively. |
Q3IconView::ExactMatch | 0x00010 | The target and search strings must match exactly. |
Q3IconView::BeginsWith | 0x00002 | The target string begins with the search string. |
Q3IconView::EndsWith | 0x00004 | The target string ends with the search string. |
Q3IconView::Contains | 0x00008 | The target string contains the search string. |
If you OR these flags together (excludingCaseSensitive), the search criteria be applied in the following order:ExactMatch,BeginsWith,EndsWith,Contains.
Matching is case-insensitive unlessCaseSensitive is set.CaseSensitive can be OR-ed with any combination of the other flags.
See alsoComparisonFlags.
This property holds the arrangement mode of the icon view.
This can beLeftToRight orTopToBottom. The default isLeftToRight.
Access functions:
| Arrangement | arrangement() const |
| virtual void | setArrangement(Arrangement am) |
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 callsarrangeItemsInGrid().
Access functions:
| bool | autoArrange() const |
| virtual void | setAutoArrange(bool b) |
This property holds the number of items in the icon view.
Access functions:
| uint | count() const |
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 overridessetMaxItemWidth().
Access functions:
| int | gridX() const |
| virtual void | setGridX(int rx) |
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) |
This property holds the brush to use when drawing the background of an item's text.
By default this brush is set toQt::NoBrush, meaning that only the normal icon view background is used.
Access functions:
| QBrush | itemTextBackground() const |
| virtual void | setItemTextBackground(const QBrush & b) |
This property holds the position where the text of each item is drawn.
Valid values areBottom orRight. The default isBottom.
Access functions:
| ItemTextPos | itemTextPos() const |
| virtual void | setItemTextPos(ItemTextPos pos) |
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) |
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) |
This property holds the maximum width that an item may have.
The default is 100 pixels.
Note that if thegridX() value is setQ3IconView will ignore this property.
Access functions:
| int | maxItemWidth() const |
| virtual void | setMaxItemWidth(int w) |
This property holds the resize mode of the icon view.
This can beFixed orAdjust. The default isFixed. SeeResizeMode.
Access functions:
| ResizeMode | resizeMode() const |
| virtual void | setResizeMode(ResizeMode am) |
This property holds the selection mode of the icon view.
This can beSingle (the default),Extended,Multi orNoSelection.
Access functions:
| SelectionMode | selectionMode() const |
| virtual void | setSelectionMode(SelectionMode m) |
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 ifsetWordWrapIconText() is true, as it is by default.
Access functions:
| bool | showToolTips() const |
| virtual void | setShowToolTips(bool b) |
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 bothsorting() andautoArrange() are true.
To set the sort direction, usesetSorting()
Access functions:
| bool | sortDirection() const |
This property holds whether the icon view sorts on insertion.
The default is false, i.e. no sorting on insertion.
To set the sorting, usesetSorting().
Access functions:
| bool | sorting() const |
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) |
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; seesetShowToolTips().
Access functions:
| bool | wordWrapIconText() const |
| virtual void | setWordWrapIconText(bool b) |
Constructs an empty icon view calledname, with parentparent and using the widget flagsf.
[virtual]Q3IconView::~Q3IconView()Destroys the icon view and deletes all items.
[virtual protected slot]void Q3IconView::adjustItems()Adjusts the positions of the items to the geometry of the icon view.
[virtual slot]void Q3IconView::arrangeItemsInGrid(constQSize & grid,bool update = true)This variant usesgrid instead of (gridX(),gridY()). Ifgrid is invalid (seeQSize::isValid()), arrangeItemsInGrid() calculates a valid grid itself and uses that.
Ifupdate is true (the default) the viewport is repainted.
[virtual slot]void Q3IconView::arrangeItemsInGrid(bool update = true)This is an overloaded function.
Arranges all the items in the grid specified bygridX() andgridY().
Even ifsorting() is enabled, the items are not sorted by this function. If you want to sort or rearrange the items, use iconview->sort(iconview->sortDirection()).
Ifupdate is true (the default), the viewport is repainted as well.
See alsoQ3IconView::setGridX(),Q3IconView::setGridY(), andQ3IconView::sort().
[virtual protected]void Q3IconView::changeEvent(QEvent * ev)Reimplemented fromQWidget::changeEvent().
[virtual]void Q3IconView::clear()Clears the icon view. All items are deleted.
[virtual]void Q3IconView::clearSelection()Unselects all the items.
[signal]void Q3IconView::clicked(Q3IconViewItem * item)This signal is emitted when the user clicks any mouse button. Ifitem is non-null, the cursor is onitem. Ifitem is null, the mouse cursor isn't on any item.
Note:Signalclicked is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3IconView,static_cast<void(Q3IconView::*)(Q3IconViewItem*)>(&Q3IconView::clicked),[=](Q3IconViewItem*item){/* ... */ });
See alsomouseButtonClicked(),rightButtonClicked(), andpressed().
[signal]void Q3IconView::clicked(Q3IconViewItem * item, constQPoint & pos)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.)
Note:Signalclicked is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3IconView,static_cast<void(Q3IconView::*)(Q3IconViewItem*,constQPoint&)>(&Q3IconView::clicked),[=](Q3IconViewItem*item,constQPoint&pos){/* ... */ });
See alsomouseButtonClicked(),rightButtonClicked(), andpressed().
[virtual protected]void Q3IconView::contentsContextMenuEvent(QContextMenuEvent * e)Reimplemented fromQ3ScrollView::contentsContextMenuEvent().
[virtual protected]void Q3IconView::contentsDragEnterEvent(QDragEnterEvent * e)Reimplemented fromQ3ScrollView::contentsDragEnterEvent().
[virtual protected]void Q3IconView::contentsDragLeaveEvent(QDragLeaveEvent * e)Reimplemented fromQ3ScrollView::contentsDragLeaveEvent().
[virtual protected]void Q3IconView::contentsDragMoveEvent(QDragMoveEvent * e)Reimplemented fromQ3ScrollView::contentsDragMoveEvent().
[virtual protected]void Q3IconView::contentsDropEvent(QDropEvent * e)Reimplemented fromQ3ScrollView::contentsDropEvent().
[virtual protected]void Q3IconView::contentsMouseDoubleClickEvent(QMouseEvent * e)Reimplemented fromQ3ScrollView::contentsMouseDoubleClickEvent().
[virtual protected]void Q3IconView::contentsMouseMoveEvent(QMouseEvent * e)Reimplemented fromQ3ScrollView::contentsMouseMoveEvent().
[virtual protected]void Q3IconView::contentsMousePressEvent(QMouseEvent * e)Reimplemented fromQ3ScrollView::contentsMousePressEvent().
[virtual protected]void Q3IconView::contentsMouseReleaseEvent(QMouseEvent * e)Reimplemented fromQ3ScrollView::contentsMouseReleaseEvent().
[signal]void Q3IconView::contextMenuRequested(Q3IconViewItem * item, constQPoint & pos)This signal is emitted when the user invokes a context menu with the right mouse button or with special system keys, withitem 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.
[signal]void Q3IconView::currentChanged(Q3IconViewItem * item)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 alsocurrentItem().
Returns a pointer to the current item of the icon view, or 0 if no item is current.
See alsosetCurrentItem(),firstItem(), andlastItem().
[virtual protected slot]void Q3IconView::doAutoScroll()Performs autoscrolling when selecting multiple icons with the rubber band.
[signal]void Q3IconView::doubleClicked(Q3IconViewItem * item)This signal is emitted when the user double-clicks onitem.
[virtual protected]Q3DragObject * Q3IconView::dragObject()Returns theQ3DragObject 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 alsoQ3IconDrag.
[virtual protected]void Q3IconView::drawBackground(QPainter * p, constQRect & r)This function is called to draw the rectangler of the background using the painterp.
The default implementation fillsr with the viewport's backgroundBrush(). Subclasses can reimplement this to draw custom backgrounds.
See alsodrawContents().
[virtual protected]void Q3IconView::drawContents(QPainter * p,int cx,int cy,int cw,int ch)Reimplemented fromQ3ScrollView::drawContents().
[virtual protected]void Q3IconView::drawRubber(QPainter * p)Draws the rubber band using the painterp.
[signal]void Q3IconView::dropped(QDropEvent * e, constQ3ValueList<Q3IconDragItem> & lst)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 aQ3IconDrag,lst contains the list of the dropped items. You can get the data usingQ3IconDragItem::data() on each item. If thelst is empty, i.e. the drag was not aQ3IconDrag, you have to decode the data ine and work with that.
Note Q3IconViewItems may be drop targets; if a drop event occurs on an item the item handles the drop.
[protected]void Q3IconView::emitSelectionChanged(Q3IconViewItem * i = 0)Emits a signal to indicate selection changes.i is theQ3IconViewItem that was selected or de-selected.
You should never need to call this function.
Makes sure thatitem is entirely visible. If necessary, ensureItemVisible() scrolls the icon view.
See alsoensureVisible().
[virtual protected]void Q3IconView::enterEvent(QEvent * e)Reimplemented fromQWidget::enterEvent().
[virtual]bool Q3IconView::eventFilter(QObject * o,QEvent * e)Reimplemented fromQObject::eventFilter().
Finds the first item whose bounding rectangle overlapsr and returns a pointer to that item.r is given in content coordinates. Returns 0 if no item overlapsr.
If you want to find all items that touchr, you will need to use this function and nextItem() in a loop ending atfindLastVisibleItem() and testQ3IconViewItem::rect() for each of these items.
See alsofindLastVisibleItem() andQ3IconViewItem::rect().
Returns a pointer to the item that contains pointpos, which is given in contents coordinates, or 0 if no item contains pointpos.
This is an overloaded function.
Returns a pointer to the first item whose text begins withtext, or 0 if no such item could be found. Use thecompare flag to control the comparison behavior.
Finds the last item whose bounding rectangle overlapsr and returns a pointer to that item.r is given in content coordinates. Returns 0 if no item overlapsr.
See alsofindFirstVisibleItem().
Returns a pointer to the first item of the icon view, or 0 if there are no items in the icon view.
See alsolastItem() andcurrentItem().
[virtual protected]void Q3IconView::focusInEvent(QFocusEvent * e)Reimplemented fromQWidget::focusInEvent().
[virtual protected]void Q3IconView::focusOutEvent(QFocusEvent * e)Reimplemented fromQWidget::focusOutEvent().
Returns the index ofitem, or -1 ifitem doesn't exist in this icon view.
[virtual]QVariant Q3IconView::inputMethodQuery(Qt::InputMethodQuery query) constReimplemented fromQWidget::inputMethodQuery().
[virtual protected]void Q3IconView::insertInGrid(Q3IconViewItem * item)Inserts theQ3IconViewItemitem in the icon view's grid.You should never need to call this function. Instead, insert Q3IconViewItems by creating them with a pointer to theQ3IconView that they are to be inserted into.
[virtual]void Q3IconView::insertItem(Q3IconViewItem * item,Q3IconViewItem * after = 0L)Inserts the icon view itemitem afterafter. Ifafter is 0,item is appended after the last item.
You should never need to call this function. Instead createQ3IconViewItem's and associate them with your icon view like this:
(void)newQ3IconViewItem(myIconview,"The text of the item", aPixmap);
[virtual]void Q3IconView::invertSelection()Inverts the selection. Works only in Multi and Extended selection mode.
Returns true if an iconview item is being renamed; otherwise returns false.
[signal]void Q3IconView::itemRenamed(Q3IconViewItem * item, constQString & name)This signal is emitted whenitem has been renamed toname, usually by in-place renaming.
Note:SignalitemRenamed is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3IconView,static_cast<void(Q3IconView::*)(Q3IconViewItem*,constQString&)>(&Q3IconView::itemRenamed),[=](Q3IconViewItem*item,constQString&name){/* ... */ });
See alsoQ3IconViewItem::setRenameEnabled() andQ3IconViewItem::rename().
[signal]void Q3IconView::itemRenamed(Q3IconViewItem * item)This is an overloaded function.
This signal is emitted whenitem has been renamed, usually by in-place renaming.
Note:SignalitemRenamed is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3IconView,static_cast<void(Q3IconView::*)(Q3IconViewItem*)>(&Q3IconView::itemRenamed),[=](Q3IconViewItem*item){/* ... */ });
See alsoQ3IconViewItem::setRenameEnabled() andQ3IconViewItem::rename().
[virtual protected]void Q3IconView::keyPressEvent(QKeyEvent * e)Reimplemented fromQWidget::keyPressEvent().
Returns a pointer to the last item of the icon view, or 0 if there are no items in the icon view.
See alsofirstItem() andcurrentItem().
[protected]Q3IconViewItem * Q3IconView::makeRowLayout(Q3IconViewItem * begin,int & y,bool & changed)Lays out a row of icons (if Arrangement ==TopToBottom this is a column). Starts laying out with the itembegin.y is the starting coordinate. Returns the last item of the row (column) and sets the new starting coordinate toy. Thechanged parameter is used internally.
Warning: This function may be made private in a future version of Qt. We do not recommend calling it.
[virtual]QSize Q3IconView::minimumSizeHint() constReimplemented fromQWidget::minimumSizeHint().
[signal]void Q3IconView::mouseButtonClicked(int button,Q3IconViewItem * item, constQPoint & pos)This signal is emitted when the user clicks mouse buttonbutton. Ifitem is non-null, the cursor is onitem. Ifitem 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 alsomouseButtonPressed(),rightButtonClicked(), andclicked().
[signal]void Q3IconView::mouseButtonPressed(int button,Q3IconViewItem * item, constQPoint & pos)This signal is emitted when the user presses mouse buttonbutton. Ifitem is non-null, the cursor is onitem. Ifitem 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 alsorightButtonClicked(),mouseButtonClicked(), andpressed().
[signal]void Q3IconView::moved()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.
[signal]void Q3IconView::onItem(Q3IconViewItem * item)This signal is emitted when the user moves the mouse cursor onto anitem, similar to theQWidget::enterEvent() function.
[signal]void Q3IconView::onViewport()This signal is emitted when the user moves the mouse cursor from an item to an empty part of the icon view.
See alsoonItem().
[signal]void Q3IconView::pressed(Q3IconViewItem * item)This signal is emitted when the user presses any mouse button. Ifitem is non-null, the cursor is onitem. Ifitem is null, the mouse cursor isn't on any item.
Note:Signalpressed is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3IconView,static_cast<void(Q3IconView::*)(Q3IconViewItem*)>(&Q3IconView::pressed),[=](Q3IconViewItem*item){/* ... */ });
See alsomouseButtonPressed(),rightButtonPressed(), andclicked().
[signal]void Q3IconView::pressed(Q3IconViewItem * item, constQPoint & pos)This is an overloaded function.
This signal is emitted when the user presses any mouse button. Ifitem is non-null, the cursor is onitem. Ifitem 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.)
Note:Signalpressed is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3IconView,static_cast<void(Q3IconView::*)(Q3IconViewItem*,constQPoint&)>(&Q3IconView::pressed),[=](Q3IconViewItem*item,constQPoint&pos){/* ... */ });
See alsomouseButtonPressed(),rightButtonPressed(), andclicked().
[virtual]void Q3IconView::repaintItem(Q3IconViewItem * item)Repaints theitem.
Repaints the selected items.
[virtual protected]void Q3IconView::resizeEvent(QResizeEvent * e)Reimplemented fromQWidget::resizeEvent().
[signal]void Q3IconView::returnPressed(Q3IconViewItem * item)This signal is emitted if the user presses the Return or Enter key.item is thecurrentItem() at the time of the keypress.
[signal]void Q3IconView::rightButtonClicked(Q3IconViewItem * item, constQPoint & pos)This signal is emitted when the user clicks the right mouse button. Ifitem is non-null, the cursor is onitem. Ifitem 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 alsorightButtonPressed(),mouseButtonClicked(), andclicked().
[signal]void Q3IconView::rightButtonPressed(Q3IconViewItem * item, constQPoint & pos)This signal is emitted when the user presses the right mouse button. Ifitem is non-null, the cursor is onitem. Ifitem 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()).
[virtual]void Q3IconView::selectAll(bool select)In Multi and Extended modes, this function sets all items to be selected ifselect is true, and to be unselected ifselect is false.
In Single andNoSelection modes, this function only changes the selection status ofcurrentItem().
[signal]void Q3IconView::selectionChanged()This signal is emitted when the selection has been changed. It's emitted in each selection mode.
Note:SignalselectionChanged is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3IconView,static_cast<void(Q3IconView::*)()>(&Q3IconView::selectionChanged),[=](){/* ... */ });
[signal]void Q3IconView::selectionChanged(Q3IconViewItem * item)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.
Note:SignalselectionChanged is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3IconView,static_cast<void(Q3IconView::*)(Q3IconViewItem*)>(&Q3IconView::selectionChanged),[=](Q3IconViewItem*item){/* ... */ });
[virtual slot]void Q3IconView::setContentsPos(int x,int y)Reimplemented fromQ3ScrollView::setContentsPos().
[virtual]void Q3IconView::setCurrentItem(Q3IconViewItem * item)Makesitem the new current item of the icon view.
See alsocurrentItem().
[virtual]void Q3IconView::setSelected(Q3IconViewItem * item,bool s,bool cb = false)Selects or unselectsitem depending ons, and may also unselect other items, depending onQ3IconView::selectionMode() andcb.
Ifs is false,item is unselected.
Ifs is true andQ3IconView::selectionMode() isSingle,item is selected, and the item which was selected is unselected.
Ifs is true andQ3IconView::selectionMode() isExtended,item is selected. Ifcb is true, the selection state of the icon view's other items is left unchanged. Ifcb is false (the default) all other items are unselected.
Ifs is true andQ3IconView::selectionMode() isMultiitem is selected.
Note thatcb is used only ifQ3IconView::selectionMode() isExtended.cb defaults to false.
All items whose selection status is changed repaint themselves.
Ifsort is true, this function sets the icon view to sort items when a new item is inserted. Ifsort is false, the icon view will not be sorted.
Note thatautoArrange() must be true for sorting to take place.
Ifascending is true (the default), items are sorted in ascending order. Ifascending 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 alsosorting(),Q3IconView::setAutoArrange(),Q3IconView::autoArrange(),sortDirection(),sort(), andQ3IconViewItem::setKey().
[virtual]void Q3IconView::showEvent(QShowEvent *)Reimplemented fromQWidget::showEvent().
[virtual]QSize Q3IconView::sizeHint() constReimplemented fromQWidget::sizeHint().
[virtual protected slot]void Q3IconView::slotUpdate()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 aQTimer. 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.
[virtual]void Q3IconView::sort(bool ascending = true)Sorts and rearranges all the items in the icon view. Ifascending 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 toascending.
See alsoQ3IconViewItem::key(),Q3IconViewItem::setKey(),Q3IconViewItem::compare(),Q3IconView::setSorting(), andQ3IconView::sortDirection().
[virtual protected]void Q3IconView::startDrag()Starts a drag.
[virtual]void Q3IconView::takeItem(Q3IconViewItem * item)Takes the icon view itemitem 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.
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.