Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

  • Qt 4.8
  • Qt3SupportLight
  • Q3IconView

Q3IconView Class

TheQ3IconView class provides an area with movable labelled icons.More...

Header:#include <Q3IconView>
Inherits:Q3ScrollView

Public Types

enumArrangement { LeftToRight, TopToBottom }
typedefComparisonFlags
enumItemTextPos { Bottom, Right }
enumResizeMode { Fixed, Adjust }
enumSelectionMode { Single, Multi, Extended, NoSelection }
enumStringComparisonMode { CaseSensitive, ExactMatch, BeginsWith, EndsWith, Contains }

Properties

Public Functions

Q3IconView(QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0)
virtual~Q3IconView()
Arrangementarrangement() const
boolautoArrange() const
virtual voidclear()
virtual voidclearSelection()
uintcount() const
Q3IconViewItem *currentItem() const
voidensureItemVisible(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
intgridX() const
intgridY() const
intindex(const Q3IconViewItem * item) const
virtual voidinsertItem(Q3IconViewItem * item, Q3IconViewItem * after = 0L)
virtual voidinvertSelection()
boolisRenaming() const
QBrushitemTextBackground() const
ItemTextPositemTextPos() const
boolitemsMovable() const
Q3IconViewItem *lastItem() const
intmaxItemTextLength() const
intmaxItemWidth() const
virtual voidrepaintItem(Q3IconViewItem * item)
voidrepaintSelectedItems()
ResizeModeresizeMode() const
virtual voidselectAll(bool select)
SelectionModeselectionMode() const
virtual voidsetArrangement(Arrangement am)
virtual voidsetAutoArrange(bool b)
virtual voidsetCurrentItem(Q3IconViewItem * item)
virtual voidsetGridX(int rx)
virtual voidsetGridY(int ry)
virtual voidsetItemTextBackground(const QBrush & b)
virtual voidsetItemTextPos(ItemTextPos pos)
virtual voidsetItemsMovable(bool b)
virtual voidsetMaxItemTextLength(int w)
virtual voidsetMaxItemWidth(int w)
virtual voidsetResizeMode(ResizeMode am)
virtual voidsetSelected(Q3IconViewItem * item, bool s, bool cb = false)
virtual voidsetSelectionMode(SelectionMode m)
virtual voidsetShowToolTips(bool b)
voidsetSorting(bool sort, bool ascending = true)
virtual voidsetSpacing(int sp)
virtual voidsetWordWrapIconText(bool b)
boolshowToolTips() const
virtual voidsort(bool ascending = true)
boolsortDirection() const
boolsorting() const
intspacing() const
virtual voidtakeItem(Q3IconViewItem * item)
boolwordWrapIconText() const

Reimplemented Public Functions

virtual booleventFilter(QObject * o, QEvent * e)
virtual QVariantinputMethodQuery(Qt::InputMethodQuery query) const
virtual QSizeminimumSizeHint() const
virtual voidshowEvent(QShowEvent *)
virtual QSizesizeHint() const
  • 49 public functions inherited fromQ3ScrollView
  • 4 public functions inherited fromQ3Frame
  • 14 public functions inherited fromQFrame
  • 220 public functions inherited fromQWidget
  • 29 public functions inherited fromQObject
  • 12 public functions inherited fromQPaintDevice

Public Slots

virtual voidarrangeItemsInGrid(const QSize & grid, bool update = true)
virtual voidarrangeItemsInGrid(bool update = true)
virtual voidsetContentsPos(int x, int y)

Signals

voidclicked(Q3IconViewItem * item)
voidclicked(Q3IconViewItem * item, const QPoint & pos)
voidcontextMenuRequested(Q3IconViewItem * item, const QPoint & pos)
voidcurrentChanged(Q3IconViewItem * item)
voiddoubleClicked(Q3IconViewItem * item)
voiddropped(QDropEvent * e, const Q3ValueList<Q3IconDragItem> & lst)
voiditemRenamed(Q3IconViewItem * item, const QString & name)
voiditemRenamed(Q3IconViewItem * item)
voidmouseButtonClicked(int button, Q3IconViewItem * item, const QPoint & pos)
voidmouseButtonPressed(int button, Q3IconViewItem * item, const QPoint & pos)
voidmoved()
voidonItem(Q3IconViewItem * item)
voidonViewport()
voidpressed(Q3IconViewItem * item)
voidpressed(Q3IconViewItem * item, const QPoint & pos)
voidreturnPressed(Q3IconViewItem * item)
voidrightButtonClicked(Q3IconViewItem * item, const QPoint & pos)
voidrightButtonPressed(Q3IconViewItem * item, const QPoint & pos)
voidselectionChanged()
voidselectionChanged(Q3IconViewItem * item)

Protected Functions

virtual Q3DragObject *dragObject()
virtual voiddrawBackground(QPainter * p, const QRect & r)
virtual voiddrawRubber(QPainter * p)
voidemitSelectionChanged(Q3IconViewItem * i = 0)
virtual voidinsertInGrid(Q3IconViewItem * item)
Q3IconViewItem *makeRowLayout(Q3IconViewItem * begin, int & y, bool & changed)
virtual voidstartDrag()

Reimplemented Protected Functions

virtual voidchangeEvent(QEvent * ev)
virtual voidcontentsContextMenuEvent(QContextMenuEvent * e)
virtual voidcontentsDragEnterEvent(QDragEnterEvent * e)
virtual voidcontentsDragLeaveEvent(QDragLeaveEvent * e)
virtual voidcontentsDragMoveEvent(QDragMoveEvent * e)
virtual voidcontentsDropEvent(QDropEvent * e)
virtual voidcontentsMouseDoubleClickEvent(QMouseEvent * e)
virtual voidcontentsMouseMoveEvent(QMouseEvent * e)
virtual voidcontentsMousePressEvent(QMouseEvent * e)
virtual voidcontentsMouseReleaseEvent(QMouseEvent * e)
virtual voiddrawContents(QPainter * p, int cx, int cy, int cw, int ch)
virtual voidenterEvent(QEvent * e)
virtual voidfocusInEvent(QFocusEvent * e)
virtual voidfocusOutEvent(QFocusEvent * e)
virtual voidkeyPressEvent(QKeyEvent * e)
virtual voidresizeEvent(QResizeEvent * e)
  • 26 protected functions inherited fromQ3ScrollView
  • 5 protected functions inherited fromQ3Frame
  • 3 protected functions inherited fromQFrame
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice

Protected Slots

virtual voidadjustItems()
virtual voiddoAutoScroll()
virtual voidslotUpdate()
  • 1 protected slot inherited fromQWidget

Additional Inherited Members

  • 4 static public members inherited fromQWidget
  • 7 static public members inherited fromQObject

Detailed Description

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:

  • CallsetArrangement(), e.g. withTopToBottom which will fill thetop-most row from left to right, then moves one rowdown and fills that row from left to right and so on.
  • Construct eachQ3IconViewItem using a constructor which allows you to specify which item the new one is to follow.
  • CallsetSorting() orsort() to sort the items.

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

Drag and Drop

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

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 inQ3IconView's API for values that are OR'd combinations ofStringComparisonMode values.

See alsoStringComparisonMode.

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 tellQ3IconView 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 byQ3IconView 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, usingQ3IconView::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; andNoSelection 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 (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.

Property Documentation

arrangement :Arrangement

This property holds the arrangement mode of the icon view.

This can beLeftToRight orTopToBottom. The default isLeftToRight.

Access functions:

Arrangementarrangement() const
virtual voidsetArrangement(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 callsarrangeItemsInGrid().

Access functions:

boolautoArrange() const
virtual voidsetAutoArrange(bool b)

count : constuint

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

Access functions:

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

Access functions:

intgridX() const
virtual voidsetGridX(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:

intgridY() const
virtual voidsetGridY(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 toQt::NoBrush, meaning that only the normal icon view background is used.

Access functions:

QBrushitemTextBackground() const
virtual voidsetItemTextBackground(const QBrush & b)

itemTextPos :ItemTextPos

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

Valid values areBottom orRight. The default isBottom.

Access functions:

ItemTextPositemTextPos() const
virtual voidsetItemTextPos(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:

boolitemsMovable() const
virtual voidsetItemsMovable(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:

intmaxItemTextLength() const
virtual voidsetMaxItemTextLength(int w)

maxItemWidth :int

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:

intmaxItemWidth() const
virtual voidsetMaxItemWidth(int w)

resizeMode :ResizeMode

This property holds the resize mode of the icon view.

This can beFixed orAdjust. The default isFixed. SeeResizeMode.

Access functions:

ResizeModeresizeMode() const
virtual voidsetResizeMode(ResizeMode am)

selectionMode :SelectionMode

This property holds the selection mode of the icon view.

This can beSingle (the default),Extended,Multi orNoSelection.

Access functions:

SelectionModeselectionMode() const
virtual voidsetSelectionMode(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 ifsetWordWrapIconText() is true, as it is by default.

Access functions:

boolshowToolTips() const
virtual voidsetShowToolTips(bool b)

sortDirection : constbool

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:

boolsortDirection() const

sorting : constbool

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:

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

intspacing() const
virtual voidsetSpacing(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; seesetShowToolTips().

Access functions:

boolwordWrapIconText() const
virtual voidsetWordWrapIconText(bool b)

Member Function Documentation

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

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

Q3IconViewItem * Q3IconView::currentItem() const

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.

void Q3IconView::ensureItemVisible(Q3IconViewItem * item)

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

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

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

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

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

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

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.

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

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

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

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

Reimplemented fromQWidget::focusInEvent().

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

Reimplemented fromQWidget::focusOutEvent().

int Q3IconView::index(constQ3IconViewItem * item) const

Returns the index ofitem, or -1 ifitem doesn't exist in this icon view.

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

Reimplemented 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.

bool Q3IconView::isRenaming() const

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

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

Reimplemented 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.

void Q3IconView::repaintSelectedItems()

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.

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

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

Reimplemented 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.


[8]ページ先頭

©2009-2025 Movatter.jp