QIconView(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

✨ NAME ✨

okay bestie, welcome to the QIconView(3qt) page. QIconView is an area with movable labelled icons β€” it's giving desktop-folder energy but make it Qt. πŸ’…


🌈 SYNOPSIS 🌈

First thing: you include this header, and QIconView inherits from QScrollView. Then there's a whole roster of public members, slots, signals, properties, protected members and protected slots. I'm listing every single one, exactly as written, because we do not skip. 🫢

#include <qiconview.h>

Inherits QScrollView.

🫢 Public Members 🫢

bestie, here's the entire public member menu. Every signature, no edits, no cap.
enum SelectionMode { Single = 0, Multi, Extended, NoSelection }
enum Arrangement { LeftToRight = 0, TopToBottom }
enum ResizeMode { Fixed = 0, Adjust }
enum ItemTextPos { Bottom = 0, Right }
QIconView ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )
virtual ~QIconView ()
virtual void insertItem ( QIconViewItem * item, QIconViewItem * after = 0L )
virtual void takeItem ( QIconViewItem * item )
int index ( const QIconViewItem * item ) const
QIconViewItem * firstItem () const
QIconViewItem * lastItem () const
QIconViewItem * currentItem () const
virtual void setCurrentItem ( QIconViewItem * item )
virtual void setSelected ( QIconViewItem * item, bool s, bool cb = FALSE )
uint count () const
virtual void setSelectionMode ( SelectionMode m )
SelectionMode selectionMode () const
QIconViewItem * findItem ( const QPoint & pos ) const
QIconViewItem * findItem ( const QString & text, ComparisonFlags compare = BeginsWith ) const
virtual void selectAll ( bool select )
virtual void clearSelection ()
virtual void invertSelection ()
virtual void repaintItem ( QIconViewItem * item )
void repaintSelectedItems ()
void ensureItemVisible ( QIconViewItem * item )
QIconViewItem * findFirstVisibleItem ( const QRect & r ) const
QIconViewItem * findLastVisibleItem ( const QRect & r ) const
virtual void clear ()
virtual void setGridX ( int rx )
virtual void setGridY ( int ry )
int gridX () const
int gridY () const
virtual void setSpacing ( int sp )
int spacing () const
virtual void setItemTextPos ( ItemTextPos pos )
ItemTextPos itemTextPos () const
virtual void setItemTextBackground ( const QBrush & b )
QBrush itemTextBackground () const
virtual void setArrangement ( Arrangement am )
Arrangement arrangement () const
virtual void setResizeMode ( ResizeMode am )
ResizeMode resizeMode () const
virtual void setMaxItemWidth ( int w )
int maxItemWidth () const
virtual void setMaxItemTextLength ( int w )
int maxItemTextLength () const
virtual void setAutoArrange ( bool b )
bool autoArrange () const
virtual void setShowToolTips ( bool b )
bool showToolTips () const
void setSorting ( bool sort, bool ascending = TRUE )
bool sorting () const
bool sortDirection () const
virtual void setItemsMovable ( bool b )
bool itemsMovable () const
virtual void setWordWrapIconText ( bool b )
bool wordWrapIconText () const
virtual void sort ( bool ascending = TRUE )
bool isRenaming () const

πŸŽ€ Public Slots πŸŽ€

virtual void arrangeItemsInGrid ( const QSize & grid, bool update = TRUE )
virtual void arrangeItemsInGrid ( bool update = TRUE )

πŸ¦‹ Signals πŸ¦‹

the icon view is literally so chatty, and we love that for it.
void selectionChanged ()
void selectionChanged ( QIconViewItem * item )
void currentChanged ( QIconViewItem * item )
void clicked ( QIconViewItem * item )
void clicked ( QIconViewItem * item, const QPoint & pos )
void pressed ( QIconViewItem * item )
void pressed ( QIconViewItem * item, const QPoint & pos )
void doubleClicked ( QIconViewItem * item )
void returnPressed ( QIconViewItem * item )
void rightButtonClicked ( QIconViewItem * item, const QPoint & pos )
void rightButtonPressed ( QIconViewItem * item, const QPoint & pos )
void mouseButtonPressed ( int button, QIconViewItem * item, const QPoint & pos )
void mouseButtonClicked ( int button, QIconViewItem * item, const QPoint & pos )
void contextMenuRequested ( QIconViewItem * item, const QPoint & pos )
void dropped ( QDropEvent * e, const QValueList<QIconDragItem> & lst )
void moved ()
void onItem ( QIconViewItem * item )
void onViewport ()
void itemRenamed ( QIconViewItem * item, const QString & name )
void itemRenamed ( QIconViewItem * item )

πŸ’– Properties πŸ’–

every property, every read-only note, all of it. periodt.
Arrangement arrangement - the arrangement mode of the icon view
bool autoArrange - whether the icon view rearranges its items when a new item is inserted
uint count - the number of items in the icon view  (read only)
int gridX - the horizontal grid of the icon view
int gridY - the vertical grid of the icon view
QBrush itemTextBackground - the brush to use when drawing the background of an item's text
ItemTextPos itemTextPos - the position where the text of each item is drawn
bool itemsMovable - whether the user is allowed to move items around in the icon view
int maxItemTextLength - the maximum length (in characters) that an item's text may have
int maxItemWidth - the maximum width that an item may have
ResizeMode resizeMode - the resize mode of the icon view
SelectionMode selectionMode - the selection mode of the icon view
bool showToolTips - whether the icon view will display a tool tip with the complete text for any truncated item text
bool sortDirection - whether the sort direction for inserting new items is ascending;  (read only)
bool sorting - whether the icon view sorts on insertion  (read only)
int spacing - the space in pixels between icon view items
bool wordWrapIconText - whether the item text will be word-wrapped if it is too long

🧚 Protected Members 🧚

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

🌸 Protected Slots 🌸

virtual void doAutoScroll ()
virtual void adjustItems ()
virtual void slotUpdate ()

πŸ’– DESCRIPTION πŸ’–

okay so QIconView is the class that gives you an area with movable labelled icons. It's giving file manager but make it Qt.

A QIconView can display and manage a grid or other 2D layout of labelled icons. Each labelled icon is a QIconViewItem. Items (QIconViewItems) can be added or deleted at any time; items can be moved within the QIconView. Single or multiple items can be selected. Items can be renamed in-place. QIconView 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 QIconView is to create a QIconView object and create some QIconViewItems with the QIconView as their parent, set the icon view's geometry and show it. For example:

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

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

When an item is inserted the QIconView allocates a position for it. Existing items are rearranged if autoArrange() is TRUE. The default arrangement is LeftToRight -- the QIconView 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 QIconViewItem 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 QIconView 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 QIconView 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 QIconViewItem::setKey() the new text will also serve as the key. (See QIconViewItem::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 (QIconViewItem::nextItem()) from each item in turn:

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

QIconView 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 QIconView emits a wide range of useful signals, including selectionChanged(), currentChanged(), clicked(), moved() and itemRenamed().

🌸 Drag and Drop 🌸

QIconView supports the drag and drop of items within the QIconView itself. It also supports dragging and dropping items out of or into the QIconView, plus drag and drop onto items themselves. And you can do the out-of-the-QIconView drag-and-drop thing either the simple way (basic functionality, gets the job done) or the sophisticated way (more power, more control, more main character energy). ✨

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

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

In this example we create a QTextDrag object, (derived from QDragObject), containing the item's label and return it as the drag object. And bestie, we could just as easily have created a QImageDrag from the item's pixmap and returned that instead. Options, options. πŸ’…

QIconViews and their QIconViewItems can also be the targets of drag and drops. To make the QIconView itself able to accept drops, connect to the dropped() signal. When a drop occurs this signal will be emitted with a QDragEvent and a QValueList of QIconDragItems. To make a QIconViewItem into a drop target, subclass QIconViewItem and reimplement QIconViewItem::acceptDrop() and QIconViewItem::dropped().

bool MyIconViewItem::acceptDrop( const QMimeSource *mime ) const
{
    if ( mime->provides( "text/plain" ) )
        return TRUE;
    return FALSE;
}
void MyIconViewItem::dropped( QDropEvent *evt, const QValueList<QIconDragItem>& )
{
    QString label;
    if ( QTextDrag::decode( evt, label ) )
        setText( label );
}

See iconview/simple_dd/main.h and iconview/simple_dd/main.cpp for a simple drag and drop example which demonstrates drag and drop between a QIconView and a QListBox. πŸŽ€

If you want to use extended drag-and-drop, or have drag shapes drawn, you gotta take the more sophisticated approach. No shortcuts, sorry bestie.

The first part is starting drags -- you should use a QIconDrag (or a class derived from it) for the drag object. In dragObject() create the drag object, populate it with QIconDragItems 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 QIconDragItem for each selected item, and append these items with QIconDrag::append() to the QIconDrag object. You can use QIconDragItem::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 QIconDrag, 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 QIconViewItem::acceptDrop() and QIconViewItem::dropped(). If you've used a QIconDrag (or a subclass of it) the second argument to the dropped signal contains a QValueList of QIconDragItems -- you can access their data by calling QIconDragItem::data() on each one. So easy. ✨

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

See also QIconViewItem::setDragEnabled(), QIconViewItem::setDropEnabled(), QIconViewItem::acceptDrop(), QIconViewItem::dropped(), and Advanced Widgets.

[Image Omitted]

[Image Omitted]


πŸ‘‘ Member Type Documentation πŸ‘‘

QIconView::Arrangement

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

  • QIconView::LeftToRight β€” Items which don't fit into the view cause the viewport to extend vertically (you get a vertical scrollbar).
  • QIconView::TopToBottom β€” Items which don't fit into the view cause the viewport to extend horizontally (you get a horizontal scrollbar).

QIconView::ItemTextPos

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

  • QIconView::Bottom β€” The text is drawn below the icon.
  • QIconView::Right β€” The text is drawn to the right of the icon.

QIconView::ResizeMode

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

  • QIconView::Fixed β€” The icons' positions are not changed.
  • QIconView::Adjust β€” The icons' positions are adjusted to be within the new geometry, if possible.

QIconView::SelectionMode

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

  • QIconView::Single β€” 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, using QIconView::clearSelection().)
  • QIconView::Multi β€” 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. Also, multiple items can be selected by dragging the mouse while the left mouse button stays pressed.
  • QIconView::Extended β€” 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.
  • QIconView::NoSelection β€” Items cannot be selected.

To summarise, fr fr: 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. πŸ‘€


πŸ’– MEMBER FUNCTION DOCUMENTATION πŸ’–

QIconView::QIconView ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )

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

QIconView::QIconView ( QWidget * parent = 0, const char * name = 0, WFlags f =
       0 )

QIconView::~QIconView () [virtual]

Destroys the icon view and deletes all items. Everything goes. πŸ’€


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

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


void QIconView::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.

Example: fileiconview/qfileiconview.h.


void QIconView::arrangeItemsInGrid ( bool update = TRUE ) [virtual slot]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Arranges all the items in the grid given 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()). Noted, bestie. πŸ“

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

See also QIconView::gridX, QIconView::gridY, and QIconView::sort().


Arrangement QIconView::arrangement () const

Returns the arrangement mode of the icon view. See the "arrangement" property for details.


bool QIconView::autoArrange () const

Returns TRUE if the icon view rearranges its items when a new item is inserted; otherwise returns FALSE. See the "autoArrange" property for details.


void QIconView::clear () [virtual]

Clears the icon view. All items are deleted. πŸ’…


void QIconView::clearSelection () [virtual]

Unselects all the items.


void QIconView::clicked ( QIconViewItem * 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 QIconView::clicked ( QIconViewItem * item, const QPoint & pos ) [signal]

This is an overloaded member function, provided for convenience. It behaves essentially like the above 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 QIconView::contextMenuRequested ( QIconViewItem * 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.


uint QIconView::count () const

Returns the number of items in the icon view. See the "count" property for details.


void QIconView::currentChanged ( QIconViewItem * 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().


QIconViewItem * QIconView::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 QIconView::doAutoScroll () [virtual protected slot]

Performs autoscrolling when selecting multiple icons with the rubber band.


void QIconView::doubleClicked ( QIconViewItem * item ) [signal]

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


QDragObject * QIconView::dragObject () [virtual protected]

Returns the QDragObject 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 QIconDrag.

Examples: (see above) πŸ¦‹


void QIconView::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 may reimplement this to draw custom backgrounds. ✨

See also contentsX, contentsY, and drawContents().


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

Draws the rubber band using the painter p.

πŸ’« void QIconView::dropped ( QDropEvent * e, const QValueList<QIconDragItem> & lst ) [signal]

Okay bestie, this signal goes off when a drop event happens in the viewport β€” but not on any icon β€” and the icon view itself literally cannot handle it. That's your cue. 🫢

e is giving you all the tea about the drop. And here's the cute part: if the drag object of the drop was a QIconDrag, then lst is carrying the list of the dropped items. You can pull the data out with QIconDragItem::data() on each item. ✨ But if lst is empty β€” meaning the drag was not a QIconDrag β€” then you gotta decode the data in e yourself and work with that. No shortcuts, sorry babe. πŸ’…

Heads up: QIconViewItems can be drop targets too! So if a drop event lands on an item, the item handles the drop, not you.

Examples:


πŸ› οΈ void QIconView::emitSelectionChanged ( QIconViewItem * i = 0 ) [protected]

Emits a signal to say "hey, selection changed". i is the QIconViewItem that got selected or de-selected. πŸŽ€

You should never need to call this function. Like, ever. It's an internal bestie thing. πŸ™ˆ

πŸ‘€ void QIconView::ensureItemVisible ( QIconViewItem * item )

Makes sure item is entirely visible. And if that means scrolling? Then ensureItemVisible() scrolls the icon view, no hesitation. πŸ’…

See also ensureVisible().


πŸ” QIconViewItem * QIconView::findFirstVisibleItem ( const QRect & r ) const

Finds the first item whose bounding rectangle overlaps r, and hands you back a pointer to it. r is given in content coordinates. Returns 0 if literally no item overlaps r. 😭

Now if you want to find all the items that touch r, you're gonna need to use this function together with nextItem() in a loop, ending at findLastVisibleItem(), and test QIconViewItem::rect() for each of these items. It's giving "manual iteration era" but it works. ✨

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


🎯 QIconViewItem * QIconView::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. Simple as that, bestie. πŸ’–


🎯 QIconViewItem * QIconView::findItem ( const QString & text, ComparisonFlags compare = BeginsWith ) const

This is an overloaded member function, provided for convenience. It behaves essentially like the above 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 behaviour. (See Qt::StringComparisonMode.) πŸ¦‹


πŸ” QIconViewItem * QIconView::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().


πŸ₯‡ QIconViewItem * QIconView::firstItem () const

Returns a pointer to the first item of the icon view, or 0 if there are no items in the icon view at all. Periodt. πŸ’…

See also lastItem() and currentItem().


πŸ“ int QIconView::gridX () const

Returns the horizontal grid of the icon view. See the "gridX" property for details. ✨


πŸ“ int QIconView::gridY () const

Returns the vertical grid of the icon view. See the "gridY" property for details. ✨


πŸ”’ int QIconView::index ( const QIconViewItem * item ) const

Returns the index of item, or -1 if item doesn't exist in this icon view. The -1 is giving "she's not here, girl". πŸ’€


🧩 void QIconView::insertInGrid ( QIconViewItem * item ) [virtual protected]

Inserts the QIconViewItem item in the icon view's grid.

You should never need to call this function. Instead, insert QIconViewItems by creating them with a pointer to the QIconView that they are to be inserted into. That's the move, trust. 🫢

βž• void QIconView::insertItem ( QIconViewItem * item, QIconViewItem * after = 0L ) [virtual]

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

You should never need to call this function. Instead, create QIconViewItems and associate them with your icon view like this, bestie:
(void) new QIconViewItem( myIconview, "The text of the item", aPixmap );

πŸ”„ void QIconView::invertSelection () [virtual]

Inverts the selection. And it only works in Multi and Extended selection mode. No cap. πŸ’…


✏️ bool QIconView::isRenaming () const

Returns TRUE if an iconview item is being renamed; otherwise returns FALSE. That's it, that's the whole vibe check. πŸŽ€


✏️ void QIconView::itemRenamed ( QIconViewItem * item, const QString & name ) [signal]

This signal is emitted when item has been renamed to name, usually by in-place renaming. So satisfying to watch ngl. 😭✨

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


✏️ void QIconView::itemRenamed ( QIconViewItem * item ) [signal]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function. πŸ‘‘

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

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


πŸ–ŒοΈ QBrush QIconView::itemTextBackground () const

Returns the brush to use when drawing the background of an item's text. See the "itemTextBackground" property for details. πŸ’–


πŸ“ ItemTextPos QIconView::itemTextPos () const

Returns the position where the text of each item is drawn. See the "itemTextPos" property for details. ✨


πŸ–οΈ bool QIconView::itemsMovable () const

Returns TRUE if the user is allowed to move items around in the icon view; otherwise returns FALSE. See the "itemsMovable" property for details. πŸ’…


πŸ₯‰ QIconViewItem * QIconView::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().


πŸ“ QIconViewItem * QIconView::makeRowLayout ( QIconViewItem * begin, int & y, bool & changed ) [protected]

Lays out a row of icons (if Arrangement == TopToBottom this is a column instead, sneaky). 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. Like, don't get attached bestie. 😭

πŸ”€ int QIconView::maxItemTextLength () const

Returns the maximum length (in characters) that an item's text may have. See the "maxItemTextLength" property for details. ✨


πŸ“ int QIconView::maxItemWidth () const

Returns the maximum width that an item may have. See the "maxItemWidth" property for details. πŸŽ€


πŸ–±οΈ void QIconView::mouseButtonClicked ( int button, QIconViewItem * 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()). (And 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 QIconView::mouseButtonPressed ( int button, QIconViewItem * 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() and pressed().


🚚 void QIconView::moved () [signal]

This signal is emitted after successfully dropping one (or more) items of the icon view. And if the items should be removed? It's best to do so in a slot connected to this signal. Timing is everything bestie. ✨

Example: iconview/main.cpp.


🎯 void QIconView::onItem ( QIconViewItem * item ) [signal]

This signal is emitted when the user moves the mouse cursor onto an item β€” similar to the QWidget::enterEvent() function. It's giving "entered the chat". πŸ‘‘πŸ’…


πŸ•³οΈ void QIconView::onViewport () [signal]

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

See also onItem().


πŸ–±οΈ void QIconView::pressed ( QIconViewItem * 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 QIconView::pressed ( QIconViewItem * item, const QPoint & pos ) [signal]

This is an overloaded member function, provided for convenience. It behaves essentially like the above 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 QIconView::repaintItem ( QIconViewItem * item ) [virtual]

Repaints the item. Glow up on demand. ✨


🎨 void QIconView::repaintSelectedItems ()

Repaints the selected items. All of them. Together. Iconic. πŸ’…


πŸ“ ResizeMode QIconView::resizeMode () const

Returns the resize mode of the icon view. See the "resizeMode" property for details. πŸ¦‹


⏎ void QIconView::returnPressed ( QIconViewItem * item ) [signal]

This signal is emitted if the user presses the Return or Enter key. And item is the currentItem() at the time of the keypress. Enter = send. Periodt. πŸ’…


πŸ–±οΈ void QIconView::rightButtonClicked ( QIconViewItem * 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 QIconView::rightButtonPressed ( QIconViewItem * 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 QIconView::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. Select all, deselect all, main character energy either way. πŸ‘‘

But in Single and NoSelection modes? This function only changes the selection status of currentItem(). That's it. Just the one. πŸ’…


πŸ”” void QIconView::selectionChanged () [signal]

This signal is emitted when the selection has been changed. And it's emitted in each selection mode. Every single one. No exceptions bestie. ✨


πŸ”” void QIconView::selectionChanged ( QIconViewItem * item ) [signal]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function. πŸ‘‘

This signal is emitted when the selection changes. item is the newly selected item. And heads up β€” this signal is emitted only in single selection mode. πŸ™ˆ


πŸ“‹ SelectionMode QIconView::selectionMode () const

Returns the selection mode of the icon view. See the "selectionMode" property for details. πŸŽ€


πŸ—‚οΈ void QIconView::setArrangement ( Arrangement am ) [virtual]

Sets the arrangement mode of the icon view to am. See the "arrangement" property for details. Organize ur life, bestie. βœ¨πŸ’…

void QIconView::setAutoArrange ( bool b ) [virtual] okay bestie, this one sets whether the icon view rearranges its items when a new item is inserted to b. πŸ’… See the "autoArrange" property for the deets.

void QIconView::setCurrentItem ( QIconViewItem * item ) [virtual] Makes item the new current item of the icon view. no cap, main character energy. ✨

void QIconView::setGridX ( int rx ) [virtual] Sets the horizontal grid of the icon view to rx. See the "gridX" property for the deets. 🌸

void QIconView::setGridY ( int ry ) [virtual] Sets the vertical grid of the icon view to ry. See the "gridY" property for the deets. πŸ¦‹

void QIconView::setItemTextBackground ( const QBrush & b ) [virtual] Sets the brush to use when drawing the background of an item's text to b. See the "itemTextBackground" property for the deets. πŸŽ€

void QIconView::setItemTextPos ( ItemTextPos pos ) [virtual] Sets the position where the text of each item is drawn to pos. See the "itemTextPos" property for the deets. πŸ’–

void QIconView::setItemsMovable ( bool b ) [virtual] Sets whether the user is allowed to move items around in the icon view to b. See the "itemsMovable" property for the deets. πŸ”₯

void QIconView::setMaxItemTextLength ( int w ) [virtual] Sets the maximum length (in characters) that an item's text may have to w. See the "maxItemTextLength" property for the deets. πŸ‘‘

void QIconView::setMaxItemWidth ( int w ) [virtual] Sets the maximum width that an item may have to w. See the "maxItemWidth" property for the deets. 🌈

void QIconView::setResizeMode ( ResizeMode am ) [virtual] Sets the resize mode of the icon view to am. See the "resizeMode" property for the deets. πŸ’…

void QIconView::setSelected ( QIconViewItem * item, bool s, bool cb = FALSE ) [virtual] Selects or unselects item depending on s, and may also unselect other items, depending on QIconView::selectionMode() and cb.

If s is FALSE, item is unselected.

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

If s is TRUE and QIconView::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 QIconView::selectionMode() is Multi item is selected.

Note that cb is used only if QIconView::selectionMode() is Extended. cb defaults to FALSE.

All items whose selection status is changed repaint themselves. πŸ’…

void QIconView::setSelectionMode ( SelectionMode m ) [virtual] Sets the selection mode of the icon view to m. See the "selectionMode" property for the deets. ✨

void QIconView::setShowToolTips ( bool b ) [virtual] Sets whether the icon view will display a tool tip with the complete text for any truncated item text to b. See the "showToolTips" property for the deets. πŸ’–

void QIconView::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.

QIconViewItem::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 QIconView::autoArrange, QIconView::autoArrange, sortDirection, sort(), and QIconViewItem::setKey(). πŸ¦‹

void QIconView::setSpacing ( int sp ) [virtual] Sets the space in pixels between icon view items to sp. See the "spacing" property for the deets. 🌸

void QIconView::setWordWrapIconText ( bool b ) [virtual] Sets whether the item text will be word-wrapped if it is too long to b. See the "wordWrapIconText" property for the deets. πŸŽ€

bool QIconView::showToolTips () const Returns TRUE if the icon view will display a tool tip with the complete text for any truncated item text; otherwise returns FALSE. See the "showToolTips" property for the deets. πŸ‘‘

void QIconView::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 QIconView::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.

QIconViewItem::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 QIconViewItem::key(), QIconViewItem::setKey(), QIconViewItem::compare(), QIconView::setSorting(), and QIconView::sortDirection. πŸ’…

bool QIconView::sortDirection () const Returns TRUE if the sort direction for inserting new items is ascending;; otherwise returns FALSE. See the "sortDirection" property for the deets. 🌈

bool QIconView::sorting () const Returns TRUE if the icon view sorts on insertion; otherwise returns FALSE. See the "sorting" property for the deets. ✨

int QIconView::spacing () const Returns the space in pixels between icon view items. See the "spacing" property for the deets. πŸ’–

void QIconView::startDrag () [virtual protected] Starts a drag. periodt. πŸ¦‹

void QIconView::takeItem ( QIconViewItem * 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 QIconViewItem::~QIconViewItem() calls it. The normal way to delete an item is to delete it. πŸ’…

bool QIconView::wordWrapIconText () const Returns TRUE if the item text will be word-wrapped if it is too long; otherwise returns FALSE. See the "wordWrapIconText" property for the deets. πŸŽ€


πŸŽ€ Property Documentation πŸŽ€

Arrangement arrangement

This property holds the arrangement mode of the icon view.

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

Set this property's value with setArrangement() and get this property's value with arrangement(). ✨

bool autoArrange

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, QIconView defers all position-related work until it is shown and then calls arrangeItemsInGrid().

Set this property's value with setAutoArrange() and get this property's value with autoArrange(). πŸ’–

uint count

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

Get this property's value with count(). πŸ‘‘

int gridX

This property holds the horizontal grid of the icon view.

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

Note that setting a grid width overrides setMaxItemWidth().

Set this property's value with setGridX() and get this property's value with gridX(). 🌸

int gridY

This property holds the vertical grid of the icon view.

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

Set this property's value with setGridY() and get this property's value with gridY(). πŸ¦‹

QBrush itemTextBackground

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

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

Set this property's value with setItemTextBackground() and get this property's value with itemTextBackground(). πŸŽ€

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.

Set this property's value with setItemTextPos() and get this property's value with itemTextPos(). πŸ’…

bool itemsMovable

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

The default is TRUE.

Set this property's value with setItemsMovable() and get this property's value with itemsMovable(). πŸ”₯

int maxItemTextLength

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

The default is 255 characters.

Set this property's value with setMaxItemTextLength() and get this property's value with maxItemTextLength(). ✨

int maxItemWidth

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

The default is 100 pixels.

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

Set this property's value with setMaxItemWidth() and get this property's value with maxItemWidth(). 🌈

ResizeMode resizeMode

This property holds the resize mode of the icon view.

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

Set this property's value with setResizeMode() and get this property's value with resizeMode(). πŸ’–

SelectionMode selectionMode

This property holds the selection mode of the icon view.

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

Set this property's value with setSelectionMode() and get this property's value with selectionMode(). πŸ‘‘

bool showToolTips

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.

Set this property's value with setShowToolTips() and get this property's value with showToolTips(). πŸ¦‹

bool sortDirection

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()

Get this property's value with sortDirection(). 🌸

bool sorting

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().

Get this property's value with sorting(). πŸ’…

int spacing

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

The default is 5 pixels.

Negative values for spacing are illegal.

Set this property's value with setSpacing() and get this property's value with spacing(). πŸŽ€

bool wordWrapIconText ✨

okay so bestie, this property is literally the vibe check for your icon text: do we wrap it when it's too long, or do we let it get chopped? πŸ‘€

Default? TRUE, no cap. It's giving "wrap it up, we're not monsters" πŸ’–

But if this property is FALSE? 😱 Then icon text that is too long is truncated, and an ellipsis (...) is 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 β€” peep setShowToolTips() for that magic. πŸͺ„

Set this property's value with setWordWrapIconText() and get this property's value with wordWrapIconText(). Periodt. πŸ’…


SEE ALSO πŸ‘€


Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. πŸ’–


AUTHOR ✍️

Generated automatically from the source code. Not me writing it by hand, bestie. πŸ€–


BUGS πŸ›

If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. πŸ™

The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. πŸ€·β€β™€οΈ

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qiconview.3qt) and the Qt version (3.3.8). 🐞


kisses from Trolltech AS πŸ’‹ β€” 2 February 2007 β€” QIconView(3qt) πŸ¦‹

πŸ“¦ where this page comes from