網上有很多關于pos機刷卡的翻譯,QGraphicsItem類官方文檔的中文翻譯的知識,也有很多人為大家解答關于pos機刷卡的翻譯的問題,今天pos機之家(m.shineka.com)為大家整理了關于這方面的知識,讓我們一起來看下吧!
本文目錄一覽:
pos機刷卡的翻譯
Detailed Description
It provides a light-weight foundation for writing your own custom items. This includes defining the item's geometry, collision detection, its painting implementation and item interaction through its event handlers. QGraphicsItem is part of the Graphics View Framework
它為編寫你的自定義項目提供了一個輕量級的基礎。這包括定義項目的幾何形狀,碰撞檢測,它的繪畫實現(xiàn),和通過事件處理程序的項目交互。QGraphicsItem是圖形視圖框架的一部分。
For convenience, Qt provides a set of standard graphics items for the most common shapes.
常用形狀便利函數(shù):
QGraphicsEllipseItem provides an ellipse item橢圓項目QGraphicsLineItem provides a line item直線項目QGraphicsPathItem provides an arbitrary path item路徑項目QGraphicsPixmapItem provides a pixmap item pixmap項目QGraphicsPolygonItem provides a polygon item多邊形項目QGraphicsRectItem provides a rectangular item矩形項目QGraphicsSimpleTextItem provides a simple text label item簡單文本項目QGraphicsTextItem provides an advanced text browser item文本項目All of an item's geometric information is based on its local coordinate system. The item's position, pos(), is the only function that does not operate in local coordinates, as it returns a position in parent coordinates. The Graphics View Coordinate System describes the coordinate system in detail.
項目的所有幾何信息都基于其局部坐標系統(tǒng)。項目的位置pos()是唯一不在局部坐標中操作的函數(shù),因為它返回父對象坐標中的位置。圖形視圖坐標系統(tǒng)詳細描述了坐標系統(tǒng)。
You can set whether an item should be visible (i.e., drawn, and accepting events), by calling setVisible(). Hiding an item will also hide its children. Similarly, you can enable or disable an item by calling setEnabled(). If you disable an item, all its children will also be disabled. By default, items are both visible and enabled. To toggle whether an item is selected or not, first enable selection by setting the ItemIsSelectable flag, and then call setSelected(). Normally, selection is toggled by the scene, as a result of user interaction.
setVisible()設置一個項目的可見性(例如,繪制和接受事件)。隱藏一個項目也會隱藏它的子項目。類似地,調用setEnabled()來使能一個項。如果你禁用一個項目,它的所有子項目也將被禁用。默認情況下,項目既可見又啟用。要切換項目的選中狀態(tài),先設置ItemIsSelectable標志,再調用setSelected()。通常,選中狀態(tài)切換是由場景負責,它是用戶交互產生的結果。
To write your own graphics item, you first create a subclass of QGraphicsItem, and then start by implementing its two pure virtual public functions: boundingRect(), which returns an estimate of the area painted by the item, and paint(), which implements the actual painting.
要編寫自定義圖形項,首先要創(chuàng)建QGraphicsItem的一個派生類,然后重寫它的兩個純虛函數(shù):一是boundingRect(),它返回項繪制區(qū)域的邊界矩形,二是paint(),它具體完成繪制的工作。
For example:
class SimpleItem : public QGraphicsItem
{
public:
QRectF boundingRect() const override
{
qreal penwidth="360px",height="auto" />
1;return QRectF(-10 - penwidth="360px",height="auto" />
2, -10 - penwidth="360px",height="auto" />2,20 + penwidth="360px",height="auto" />
20 + penwidth="360px",height="auto" />}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget) override
{
painter->drawRoundedRect(-10, -10, 20, 20, 5, 5);
}
};
The boundingRect() function has many different purposes. QGraphicsScene bases its item index on boundingRect(), and QGraphicsView uses it both for culling invisible items, and for determining the area that needs to be recomposed when drawing overlapping items. In addition, QGraphicsItem's collision detection mechanisms use boundingRect() to provide an efficient cut-off. The fine grained collision algorithm in collidesWithItem() is based on calling shape(), which returns an accurate outline of the item's shape as a QPainterPath.
boundingRect()函數(shù)有許多不同的用途,QGraphicsScene的項目索引基于它,QGraphicsView使用它來剔除不可見的項目,以及在繪制重疊項目時確定需要重新組合的區(qū)域。此外,QGraphicsItem的碰撞檢測機制使用boundingRect()來提供一個有效的截止。collidesWithItem()中的細粒度碰撞算法基于調用shape(),它以QPainterPath的形式返回項目形狀的精確輪廓。
QGraphicsScene expects all items boundingRect() and shape() to remain unchanged unless it is notified. If you want to change an item's geometry in any way, you must first call prepareGeometryChange() to allow QGraphicsScene to update its bookkeeping.
QGraphicsScene希望所有項目的boundingRect()和shape()保持不變,除非它被通知。如果你想以任何方式改變一個項目的幾何形狀,你必須首先調用prepareGeometryChange()來允許QGraphicsScene更新它的簿記。
Collision detection can be done in two ways:
Reimplement shape() to return an accurate shape for your item, and rely on the default implementation of collidesWithItem() to do shape-shape intersection. This can be rather expensive if the shapes are complex.Reimplement collidesWithItem() to provide your own custom item and shape collision algorithm.碰撞檢測可以通過兩種方式完成:
1. 重寫shape()方法,為你的項目返回一個精確的形狀,并依賴collidesWithItem()的默認實現(xiàn)來實現(xiàn)shape-shape交叉。如果形狀很復雜,這可能是相當昂貴的。
2. 重新實現(xiàn)collidesWithItem()來提供你自定義項目和形狀碰撞算法。
The contains() function can be called to determine whether the item contains a point or not. This function can also be reimplemented by the item. The default behavior of contains() is based on calling shape().
可以調用contains()函數(shù)來確定項目是否包含一個點。這個函數(shù)也可以由項目重新實現(xiàn)。contains()的默認行為是基于調用shape()。
Items can contain other items, and also be contained by other items. All items can have a parent item and a list of children. Unless the item has no parent, its position is in parent coordinates (i.e., the parent's local coordinates). Parent items propagate both their position and their transformation to all children.
項可以包含其他項,也可以被其他項包含。所有項都可以有一個父項和一個子項列表。除非項目沒有父項,否則它的位置在父項的坐標中(即父項的局部坐標)。父項將它們的位置和變換傳播給所有子項。
Transformations
QGraphicsItem supports projective transformations in addition to its base position, pos(). There are several ways to change an item's transformation. For simple transformations, you can call either of the convenience functions setRotation() or setScale(), or you can pass any transformation matrix to setTransform(). For advanced transformation control you also have the option of setting several combined transformations by calling setTransformations().
QGraphicsItem除了支持它的基礎位置pos()外,還支持投影變換。有幾種方法可以更改項的變換。對于簡單的轉換,你可以調用便利函數(shù)setRotation()或setScale(),或者你可以將任何轉換矩陣傳給setTransform()。對于高級變換控制,可調用setTransformations()來設置多個組合變換。
Item transformations accumulate from parent to child, so if both a parent and child item are rotated 90 degrees, the child's total transformation will be 180 degrees. Similarly, if the item's parent is scaled to 2x its original size, its children will also be twice as large. An item's transformation does not affect its own local geometry; all geometry functions (e.g., contains(), update(), and all the mapping functions) still operate in local coordinates. For convenience, QGraphicsItem provides the functions sceneTransform(), which returns the item's total transformation matrix (including its position and all parents' positions and transformations), and scenePos(), which returns its position in scene coordinates. To reset an item's matrix, call resetTransform().
項目轉換從父項目到子項目累積,因此如果父項和子項都旋轉90度,子項的總轉換將為180度。類似地,如果項的父項被縮放到其原始大小的2倍,子項也將是原大小的2倍。項目的變換不會影響它自己的局部幾何形狀;所有幾何函數(shù)(例如contains()、update()和所有映射函數(shù))仍然在局部坐標中操作。為了方便起見,QGraphicsItem提供了sceneTransform()函數(shù),它返回項目的總變換矩陣(包括它的位置和所有父元素的位置和變換),以及scenePos()函數(shù),返回它在場景坐標系中的位置。要重置項目的矩陣,調用resetTransform()。
Certain transformation operations produce a different outcome depending on the order in which they are applied. For example, if you scale an transform, and then rotate it, you may get a different result than if the transform was rotated first. However, the order you set the transformation properties on QGraphicsItem does not affect the resulting transformation; QGraphicsItem always applies the properties in a fixed, defined order:
The item's base transform is applied (transform())The item's transformations list is applied in order (transformations())The item is rotated relative to its transform origin point (rotation(), transformOriginPoint())The item is scaled relative to its transform origin point (scale(), transformOriginPoint())某些變換操作根據(jù)應用它們的順序產生不同的結果。例如,如果你縮放一個變換,然后旋轉它,你可能會得到與先旋轉變換不同的結果。但是,你在QGraphicsItem上設置變換屬性的順序不會影響產生的變換;QGraphicsItem總是以固定的、定義好的順序應用屬性:
l 項目的基本變換被應用(transform())
l 項目的變換列表按順序被應用 (transformations())
l 項目相對于其變換原點被旋轉(rotation(), transformOriginPoint())
l 項目相對于其變換原點被縮放(scale(), transformOriginPoint())
Painting
The paint() function is called by QGraphicsView to paint the item's contents. The item has no background or default fill of its own; whatever is behind the item will shine through all areas that are not explicitly painted in this function. You can call update() to schedule a repaint, optionally passing the rectangle that needs a repaint. Depending on whether or not the item is visible in a view, the item may or may not be repainted; there is no equivalent to QWidget::repaint() in QGraphicsItem.
QGraphicsView調用paint()函數(shù)來繪制項目的內容。該項目沒有自己的背景或默認填充;無論項目背后是什么,都會在所有未明確繪制的區(qū)域中發(fā)光。你可以調用update()來安排重繪,可以選擇傳遞需要重繪的矩形。根據(jù)項目在視圖中是否可見,項目可以重繪或不重繪;在QGraphicsItem中沒有與QWidget::repaint()等價的方法。
Items are painted by the view, starting with the parent items and then drawing children, in ascending stacking order. You can set an item's stacking order by calling setZValue(), and test it by calling zValue(), where items with low z-values are painted before items with high z-values. Stacking order applies to sibling items; parents are always drawn before their children.
項目由視圖繪制,從父項目開始,然后按堆升序繪制子項目。你可以通過調用setZValue()來設置項目的堆序,并通過調用zValue()來測試它,其中低z值的項目先于高z值的項目繪制。堆序適用于兄弟項;父總是先于孩繪制。
Sorting
All items are drawn in a defined, stable order, and this same order decides which items will receive mouse input first when you click on the scene. Normally you don't have to worry about sorting, as the items follow a "natural order", following the logical structure of the scene.
所有的項目都是按照一個確定的、穩(wěn)定的順序繪制的,并且當你點擊場景時,同樣的順序決定了哪些項目將首先接受鼠標輸入。通常情況下,你不必擔心排序,因為項目遵循“自然順序”,遵循場景的邏輯結構。
An item's children are stacked on top of the parent, and sibling items are stacked by insertion order (i.e., in the same order that they were either added to the scene, or added to the same parent). If you add item A, and then B, then B will be on top of A. If you then add C, the items' stacking order will be A, then B, then C.
一個項目的子項目堆疊在父項目之上,而同級項目則按插入順序堆疊(即,按照它們被添加到場景或添加到同一個父項目的順序)。如果你添加項目A,然后添加項目B,那么項目B將在項目A之上。如果然后你添加物品C,物品的堆序將是A,然后是B,然后是C。
This example shows the stacking order of all limbs of the robot from the Drag and Drop Robot example. The torso is the root item (all other items are children or descendants of the torso), so it is drawn first. Next, the head is drawn, as it is the first item in the torso's list of children. Then the upper left arm is drawn. As the lower arm is a child of the upper arm, the lower arm is then drawn, followed by the upper arm's next sibling, which is the upper right arm, and so on.
這個示例顯示了機器人所有肢體的堆序(拖放機器人示例)。軀干是根項目(所有其他項目都是軀干的子項目或后代項目),所以它是首先繪制的。接下來,畫出頭部,因為它是軀干的子列表中第一項。然后繪制左上方的手臂。由于小臂是上臂的子臂,于是繪制小臂,然后是上臂的下一個兄弟,也就是右上方的手臂,以此類推。
For advanced users, there are ways to alter how your items are sorted:
You can call setZValue() on an item to explicitly stack it on top of, or under, other sibling items. The default Z value for an item is 0. Items with the same Z value are stacked by insertion order.You can call stackBefore() to reorder the list of children. This will directly modify the insertion order.You can set the ItemStacksBehindParent flag to stack a child item behind its parent.對于高級用戶,有一些方法可以改變條目的排序方式:
l 你可以對一個條目調用setZValue()來顯式地將它堆疊在其他同級條目之上或之下。項目的默認Z值是0。具有相同Z值的項將按插入順序堆疊。
l 你可以調用stackBefore()來重新排列子列表。這將直接修改插入順序。
l 你可以設置ItemStacksBehindParent標志來將子項目堆疊在其父項目之后。
The stacking order of two sibling items also counts for each item's children and descendant items. So if one item is on top of another, then all its children will also be on top of all the other item's children as well.
兩個兄弟項目的堆疊順序也可以計算每個項目的子項目和后代項目。因此,如果一個項目在另一個項目之上,那么它的所有子項目也將在另一個項目的所有子項目之上。
Events
QGraphicsItem receives events from QGraphicsScene through the virtual function sceneEvent(). This function distributes the most common events to a set of convenience event handlers:
contextMenuEvent() handles context menu eventsfocusInEvent() and focusOutEvent() handle focus in and out eventshoverEnterEvent(), hoverMoveEvent(), and hoverLeaveEvent() handles hover enter, move and leave eventsinputMethodEvent() handles input events, for accessibility supportkeyPressEvent() and keyReleaseEvent() handle key press and release eventsmousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), and mouseDoubleClickEvent() handles mouse press, move, release, click and doubleclick eventsQGraphicsItem通過虛擬函數(shù)sceneEvent(),從QGraphicsScene接收事件。這個函數(shù)將最常見的事件分配給一組便利事件處理程序:
contextMenuEvent()處理上下文菜單事件focusInEvent()和focusOuteevent()處理焦點進入和離開事件hoverEnterEvent()、hoverMoveEvent()和hoverLeaveEvent()處理懸停進入、移動和離開事件inputMethodEvent()處理輸入事件,以獲得可訪問性支持keyPressEvent()和keyReleaseEvent()處理按鍵按下和釋放事件mousePresseEvent (), mouseMoveEvent (), mouseReleaseEvent(),和mouseDoubleClickEvent()處理鼠標按壓,移動,釋放,點擊和雙擊事件。You can filter events for any other item by installing event filters. This functionality is separate from Qt's regular event filters (see QObject::installEventFilter()), which only work on subclasses of QObject. After installing your item as an event filter for another item by calling installSceneEventFilter(), the filtered events will be received by the virtual function sceneEventFilter(). You can remove item event filters by calling removeSceneEventFilter().
你可以安裝事件過濾器,過濾任何其他項目的事件。這個功能與Qt的常規(guī)事件過濾器是分開的(參見QObject::installEventFilter()),后者只在QObject的子類上工作。通過調用installSceneEventFilter()將你的項目安裝為另一個項目的事件過濾器后,被過濾的事件將由虛擬函數(shù)sceneEventFilter()接收。你可以通過調用removeSceneEventFilter()來刪除項目事件過濾器。
Custom Data
Sometimes it's useful to register custom data with an item, be it a custom item, or a standard item. You can call setData() on any item to store data in it using a key-value pair (the key being an integer, and the value is a QVariant). To get custom data from an item, call data(). This functionality is completely untouched by Qt itself; it is provided for the user's convenience.
有時,將自定義數(shù)據(jù)注冊到一個項(無論是自定義項還是標準項)是很有用的??梢詫θ魏雾椪{用setData(),使用鍵值對(鍵是整數(shù),值是QVariant)在其中存儲數(shù)據(jù)。要從項目中獲取自定義數(shù)據(jù),調用data()。Qt本身完全沒有觸及這個功能;它是為用戶方便而提供的。
至此,圖形視圖框架的三部分都翻譯完成。
以上就是關于pos機刷卡的翻譯,QGraphicsItem類官方文檔的中文翻譯的知識,后面我們會繼續(xù)為大家整理關于pos機刷卡的翻譯的知識,希望能夠幫助到大家!
