本文整理汇总了C++中childAt函数的典型用法代码示例。如果您正苦于以下问题:C++ childAt函数的具体用法?C++ childAt怎么用?C++ childAt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了childAt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: patternSize
/**
* @brief Slot triggers drag-and-drop.
* The user start draging the pattern he wants to add to the timeline.
* @param[in] mouse pressed event.
*/
void BARPatternBarScrollAreaContents::mousePressEvent(QMouseEvent *event)
{
int x=event->pos().x(); /**< retrieves the position of the cursor. */
BARPatternBar *pBar = static_cast<BARPatternBar*>(childAt(event->pos())); /**< childAt returns a pointer to the child that was clicked. This pointer, of type "widget", is then converted into a BARPatternBar type. */
if (!pBar){return;} /**< checks that the object created isn't empty (NULL). */
QSize patternSize(100,60); /**< the following lines created a pixmap that will be displayed on the cursor during drag-and-drop. */
QPixmap pixmap(patternSize);
pixmap.fill(pBar->getBgColor());
QByteArray itemData; /**< the following lines pack up the data to be sent through the drag-and-drop. */
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
dataStream << pBar->getBgColor(); /**< stores the color of the bar being dragged. */
dataStream << pBar->getPatternLength(); /**< stores the duration of the pattern associated to the bar being dragged. */
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-dnditemdata", itemData); /**< store the data we prepared into the QMimeFile. */
mimeData->setText(childAt(event->pos())->accessibleName()); /**< store the name of the pattern associated to the bar being dragged. */
QDrag *drag = new QDrag(this); /**< crates the QDrag object. */
drag->setMimeData(mimeData); /**< stores the data we packed up into the drag object. */
drag->setPixmap(pixmap); /**< sets the image to be displayed on the cursor during the drag-and-drop. */
drag->setHotSpot(event->pos() - pBar->pos()); /**< actually displays the pixmap on the cursor during drag-and-drop. */
if (drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction) == Qt::MoveAction){pBar->close();} /**< lines found on the Internet... */
else {pBar->show();}
}
开发者ID:BdxMimo,项目名称:project-bar,代码行数:34,代码来源:barpatternbarscrollareacontents.cpp
示例2: childAt
long MainWindow::hitTest(const QPoint &pos)
{
if (IsZoomed(reinterpret_cast<HWND>(winId())))
{
auto child = childAt(pos);
if (!child || child == this)
{
return HTCAPTION;
}
return HTCLIENT;
}
bool left = pos.x() <= 5;
bool top = pos.y() <= 5;
bool right = width() - pos.x() <= 5;
bool bottom = height() - pos.y() <= 5;
if (left && top)
{
return HTTOPLEFT;
}
else if (left && bottom)
{
return HTBOTTOMLEFT;
}
else if (right && top)
{
return HTTOPRIGHT;
}
else if (right && bottom)
{
return HTBOTTOMRIGHT;
}
else if (left)
{
return HTLEFT;
}
else if (top)
{
return HTTOP;
}
else if (right)
{
return HTRIGHT;
}
else if (bottom)
{
return HTBOTTOM;
}
else
{
auto child = childAt(pos);
if (!child || child == this)
{
return HTCAPTION;
}
}
return HTCLIENT;
}
开发者ID:qinqingege,项目名称:QtDownloader,代码行数:57,代码来源:mainwindow.cpp
示例3: childAt
QTreeWidgetItem *QgsSettingsTree::createItem( const QString &text,
QTreeWidgetItem *parent, int index )
{
QTreeWidgetItem *after = 0;
if ( index != 0 )
after = childAt( parent, index - 1 );
QTreeWidgetItem *item;
if ( parent )
item = new QTreeWidgetItem( parent, after );
else
item = new QTreeWidgetItem( this, after );
item->setText( 0, text );
item->setFlags( item->flags() | Qt::ItemIsEditable );
QString key = itemKey( item );
QgsDebugMsg( key );
if ( settingsMap.contains( key ) )
{
QgsDebugMsg( "contains!!!!" );
QStringList values = settingsMap[ key ];
item->setText( 3, values.at( 0 ) );
item->setToolTip( 0, values.at( 1 ) );
item->setToolTip( 2, values.at( 1 ) );
}
// if ( settingsMap.contains(
return item;
}
开发者ID:landryb,项目名称:QGIS,代码行数:31,代码来源:qgssettingstree.cpp
示例4: mouseReleaseEvent
/*!
* Показ меню.
*/
void StatusBar::mouseReleaseEvent(QMouseEvent *event)
{
if (childAt(event->pos()) == m_icon || event->button() == Qt::RightButton)
menu(event->globalPos());
else
QStatusBar::mouseReleaseEvent(event);
}
开发者ID:johnbolia,项目名称:schat,代码行数:10,代码来源:StatusBar.cpp
示例5: raise
void Moveable::mousePressEvent( MousePressEvent& event )
{
int gx, gy;
Recti rcorner;
raise();
event.position( _lx, _ly );
size( rcorner.x, rcorner.y );
rcorner.x -= 18;
rcorner.y -= 18;
rcorner.setSize( 18, 18 );
if( rcorner.contains( _lx, _ly ) && !_togglebutton.state() ) {
_activeMode = 2;
} else {
event.position( gx, gy );
mapGlobal( gx, gy );
_activeWidget = childAt( gx, gy );
if( _activeWidget ) {
mapGlobal( event.x, event.y );
_activeWidget->mapLocal( event.x, event.y );
_activeWidget->mousePressEvent( event );
} else {
_activeMode = 1;
}
}
}
开发者ID:MajorBreakfast,项目名称:cvt,代码行数:27,代码来源:Moveable.cpp
示例6: childAt
/**
* Get a tile at a mouse position (in pixels).
* @param pos :: Position of the mouse as returned by QMouseEvent
* @return :: A pointer to the tile or NULL if clicked on an empty space.
*/
Tile *TiledWindow::getTileAtMousePos(const QPoint &pos) {
QWidget *w = childAt(pos);
auto *tile = dynamic_cast<Tile *>(w);
if (tile)
return tile;
return NULL;
}
开发者ID:liyulun,项目名称:mantid,代码行数:12,代码来源:TiledWindow.cpp
示例7: childAt
QWidget * Slider::directChildAt(const QPoint & point)
{
QWidget * childWidget = childAt(point);
while (childWidget && (childWidget->parentWidget() != _content))
childWidget = childWidget->parentWidget();
return childWidget;
}
开发者ID:BackupTheBerlios,项目名称:slicker-svn,代码行数:7,代码来源:slider.cpp
示例8: childrenSize
void FunctionGraphicsItem::calculateLayout()
{
if(elementLayout() == 0)
return;
const ElementLayout & el = *elementLayout();
QSizeF childrenSize(0,0);
QSize connectorSize = el.connector().size();
qreal minLeftPos = 0;
QList<QString> inputPositions = function()->functionInputPositions();
foreach(const QString & inputPos, inputPositions)
{
ElementGraphicsItem * child = childAt(inputPos);
if(child == 0)
continue;
QSizeF size = child->boundingRect().size();
// find the inner size of this element
childrenSize.rwidth() = qMax(childrenSize.width(), size.width());
childrenSize.rheight() += size.height();
minLeftPos = qMin(minLeftPos, child->boundingRect().left());
}
开发者ID:Dtai,项目名称:PokerbotClient,代码行数:26,代码来源:functiongraphicsitem.cpp
示例9: mousePressEvent
void DragDropArea::mousePressEvent(QMouseEvent *event)
{
QLabel *child = static_cast<QLabel*>(childAt(event->pos()));
if (!child)
return;
// Only drag children with dynamic property: "drag"
if (!child->property("drag").toBool())
return;
QPoint hotSpot = event->pos() - child->pos();
QMimeData *mimeData = new QMimeData;
mimeData->setText(child->text());
mimeData->setData("application/x-hotspot",
QByteArray::number(hotSpot.x())
+ " " + QByteArray::number(hotSpot.y()));
QPixmap pixmap(child->size());
child->render(&pixmap);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->setPixmap(pixmap);
drag->setHotSpot(hotSpot);
drag->exec();
}
开发者ID:arielmr,项目名称:SofiaTrigo,代码行数:27,代码来源:dragdroparea.cpp
示例10: childAt
/*! \brief handle double click
*
* dial or indirect transfer if left mouse button used
*/
void BasePeerWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
QWidget *w = childAt(event->pos());
QString subwidgetkind;
if (w) {
subwidgetkind = w->property("kind").toString();
}
// check if we are in communication
const UserInfo *ui = b_engine->getXivoClientUser();
if (ui && !ui->phonelist().isEmpty()) {
foreach (const QString phone, ui->phonelist()) {
const PhoneInfo *pi = ui->getPhoneInfo(phone);
const QMap<QString, QVariant> & comms = pi->comms();
//qDebug() << pi->phoneid() << pi->comms();
foreach (const QString ts, comms.keys()) {
const QMap<QString, QVariant> & comm = comms[ts].toMap();
//qDebug() << pi->phoneid() << ts << comm;
const QString status = comm["status"].toString();
if (status == CHAN_STATUS_LINKED_CALLER || status == CHAN_STATUS_LINKED_CALLED) {
QString to;
if (m_ui) {
to = "user:" + m_ui->userid();
} else {
to = "ext:" + m_number;
}
// Initiate an indirect transfer.
b_engine->actionCall("atxfer",
"chan:special:me:" + comm["thischannel"].toString(),
to);
return;
}
}
}
}
开发者ID:Eyepea,项目名称:xivo-gallifrey,代码行数:39,代码来源:basepeerwidget.cpp
示例11: mousePressEvent
void MainWindow::mousePressEvent(QMouseEvent *event)
{
//1,获取图片
QLabel *child = static_cast<QLabel*>(childAt(event->pos()));
if(!child->inherits("QLabel")) return;
QPixmap pixmap = *child->pixmap();
//2,自定义MIME类型
QByteArray itemData;
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
dataStream<<pixmap<<QPoint(event->pos()-child->pos());
//3,将数据放入QMimeData中
QMimeData *mimeData = new QMimeData;
mimeData->setData("image/png", itemData);
//4,将数据放到QDrag中
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->setPixmap(pixmap);
drag->setHotSpot(event->pos()-child->pos());
//5,原图添加阴影
QPixmap tempPixmap = pixmap;
QPainter painter;
painter.begin(&tempPixmap);
painter.fillRect(pixmap.rect(),QColor(127,127,127,127));
painter.end();
child->setPixmap(tempPixmap);
//6,执行拖放操作
if(drag->exec(Qt::CopyAction|Qt::MoveAction, Qt::CopyAction)
==Qt::MoveAction)
child->close();
else{
child->show();
child->setPixmap(pixmap);
}
}
开发者ID:enbool,项目名称:test4,代码行数:34,代码来源:mainwindow.cpp
示例12: mousePressEvent
void PlayerCardListWidget::mousePressEvent(QMouseEvent *event)
{
PlayerCardWidget *child = static_cast<PlayerCardWidget*>(childAt(event->pos()));
if (!child)
return;
// Float up the hierachy until the PlayerCardWidget is found, or we hit the current widget
while ((!child->property("PlayerCardWidget").isValid()) && ((PlayerCardListWidget*)child != this)) {
child = static_cast<PlayerCardWidget*>(child->parent());
}
// If the child is not a PlayerCardWidget, return
if (!child->property("PlayerCardWidget").isValid())
return;
QPoint hotSpot = event->pos() - child->pos();
QByteArray itemData;
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
dataStream << child->playerNumber() << QPoint(hotSpot);
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-chessplayer", itemData);
mimeData->setText(child->player()->name());
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->setPixmap(QPixmap::grabWidget(child));
drag->setHotSpot(hotSpot);
child->hide();
if (drag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction) == Qt::MoveAction)
child->close();
else
child->show();
}
开发者ID:mariusroets,项目名称:pairing,代码行数:33,代码来源:playercardlistwidget.cpp
示例13: childAt
void QTodoList::contextMenuEvent(QContextMenuEvent* event)
{
QWidget* child_at = childAt(event->pos());
if(child_at != vbox && child_at != spacer)
return;
contextMenu(event->globalPos());
}
开发者ID:tobimensch,项目名称:qtodo,代码行数:8,代码来源:qtodo_list.cpp
示例14: childAt
int QAccessibleInterfaceEx_QtDShell::__override_childAt(int x0, int y1, bool static_call) const
{
if (static_call) {
return 0;
} else {
return childAt((int )x0, (int )y1);
}
}
开发者ID:dreamsxin,项目名称:nawia,代码行数:8,代码来源:QAccessibleInterfaceEx_shell.cpp
示例15:
NPT_List<const Object*> Container::getChildren() const
{
NPT_List<const Object*> ls;
for (NPT_Ordinal i = 0; i < childCount(); i++) {
ls.Add(childAt(i));
}
return ls;
}
开发者ID:chenkaigithub,项目名称:GenieWin8,代码行数:8,代码来源:avcore4.cpp
示例16: removeChild
/** Remove the child at the specified position */
void removeChild( int pos )
{
Q_ASSERT( pos >= 0 && pos < childrenCount() );
for ( int i = pos+1; i < childrenCount(); ++i ) {
childAt( i )->mParentListPos--;
}
mChildren.removeAt( pos );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:9,代码来源:kotodomodel.cpp
示例17: childAt
int QAccessibleWidgetEx_QtDShell::__override_childAt(int x0, int y1, bool static_call) const
{
if (static_call) {
return QAccessibleWidgetEx::childAt((int )x0, (int )y1);
} else {
return childAt((int )x0, (int )y1);
}
}
开发者ID:dreamsxin,项目名称:nawia,代码行数:8,代码来源:QAccessibleWidgetEx_shell.cpp
示例18: if
bool OBSBasic::HitTestDrag(QPoint mouseWndPos, long *result)
{
//优先判断对角线方向的resize
if (mouseWndPos.y() <= m_resizeBorderWidth && mouseWndPos.x() <= m_resizeBorderWidth)
{
*result = HTTOPLEFT;
return true;
}
else if (mouseWndPos.y() <= m_resizeBorderWidth && mouseWndPos.x() >= this->width() - m_resizeBorderWidth)
{
*result = HTTOPRIGHT;
return true;
}
else if (mouseWndPos.y() >= this->height() - m_resizeBorderWidth && mouseWndPos.x() >= this->width() - m_resizeBorderWidth)
{
*result = HTBOTTOMRIGHT;
return true;
}
else if (mouseWndPos.y() >= this->height() - m_resizeBorderWidth && mouseWndPos.x() <= m_resizeBorderWidth)
{
*result = HTBOTTOMLEFT;
return true;
}
//然后判断平拉拖动
if (mouseWndPos.x() <= m_resizeBorderWidth)
{
*result = HTLEFT;
return true;
}
else if (mouseWndPos.x() >= this->width() - m_resizeBorderWidth)
{
*result = HTRIGHT;
return true;
}
else if (mouseWndPos.y() >= this->height() - m_resizeBorderWidth)
{
*result = HTBOTTOM;
return true;
}
else if (mouseWndPos.y() <= m_resizeBorderWidth)
{
*result = HTTOP;
return true;
}
else
{
QWidget *childAtWidget = childAt(mouseWndPos);
if (ui->titlewidget == childAtWidget || ui->tabArea == childAtWidget)
{
*result = HTCAPTION;
return true;
}
}
return false;
}
开发者ID:ipaste,项目名称:tblive,代码行数:57,代码来源:window-basic-main-tblive.cpp
示例19: lookup
PhysReg lookup(Vreg vreg, VregKind kind) {
auto ivl = xls.intervals[vreg];
if (!ivl || vreg.isPhys()) return vreg;
PhysReg reg = ivl->childAt(pos)->reg;
assert((kind == VregKind::Gpr && reg.isGP()) ||
(kind == VregKind::Simd && reg.isSIMD()) ||
(kind == VregKind::Any && reg != InvalidReg));
return reg;
}
开发者ID:CodeKong,项目名称:hhvm,代码行数:9,代码来源:vasm-xls.cpp
示例20: eventFilter
bool XYVirtualKeyboard::eventFilter(QObject *obj, QEvent *event)
{
static XYPushButton *lastBtn_containsMouse = NULL;
if (event->type() == QEvent::MouseMove)
{
QMouseEvent *mouse_event = (QMouseEvent *)event;
if (mouse_event->buttons() & Qt::LeftButton)
{
XYPushButton *receiversBtn = qobject_cast<XYPushButton *>(obj);
XYPushButton *btn = qobject_cast<XYPushButton *>(childAt(mapFromGlobal(mouse_event->globalPos())));
if (btn != NULL && (lastBtn_containsMouse == NULL
|| lastBtn_containsMouse != btn))
{
if (lastBtn_containsMouse != NULL)
{
lastBtn_containsMouse->mouseReleaseedOP(true, false);
}
btn->mousePressedOP();
lastBtn_containsMouse = btn;
}
else if (btn == NULL)
{
if (lastBtn_containsMouse != NULL)
{
lastBtn_containsMouse->mouseReleaseedOP(true, false);
}
else if (receiversBtn->pressed)
{
receiversBtn->mouseReleaseedOP(true, false);
}
lastBtn_containsMouse = NULL;
}
return true;
}
}
else if (event->type() == QEvent::MouseButtonRelease)
{
QMouseEvent *mouse_event = (QMouseEvent *)event;
if (mouse_event->button() == Qt::LeftButton)
{
if (lastBtn_containsMouse != NULL)
{
QPoint pos = lastBtn_containsMouse->mapFromGlobal(mouse_event->globalPos());
lastBtn_containsMouse->mouseReleaseedOP(true,
lastBtn_containsMouse->rect().contains(pos));
}
else
{
return QWidget::eventFilter(obj, event);
}
lastBtn_containsMouse = NULL;
return true;
}
}
return QWidget::eventFilter(obj, event);
}
开发者ID:Fishguys,项目名称:Soft-keyboard,代码行数:56,代码来源:xyvirtualkeyboard.cpp
注:本文中的childAt函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论