/** * @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();} }
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; }
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; }
/*! * Показ меню. */ void StatusBar::mouseReleaseEvent(QMouseEvent *event) { if (childAt(event->pos()) == m_icon || event->button() == Qt::RightButton) menu(event->globalPos()); else QStatusBar::mouseReleaseEvent(event); }
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; } } }
/** * 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; }
QWidget * Slider::directChildAt(const QPoint & point) { QWidget * childWidget = childAt(point); while (childWidget && (childWidget->parentWidget() != _content)) childWidget = childWidget->parentWidget(); return childWidget; }
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()); }
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(); }
/*! \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:"******"ext:" + m_number; } // Initiate an indirect transfer. b_engine->actionCall("atxfer", "chan:special:me:" + comm["thischannel"].toString(), to); return; } } } }
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); } }
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(); }
void QTodoList::contextMenuEvent(QContextMenuEvent* event) { QWidget* child_at = childAt(event->pos()); if(child_at != vbox && child_at != spacer) return; contextMenu(event->globalPos()); }
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); } }
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; }
/** 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 ); }
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); } }
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; }
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; }
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); }
/*! Returns the action at point \a p. This function returns zero if no action was found. \sa QWidget::childAt() */ QAction *QToolBar::actionAt(const QPoint &p) const { Q_D(const QToolBar); QWidget *widget = childAt(p); int index = d->layout->indexOf(widget); if (index == -1) return 0; QLayoutItem *item = d->layout->itemAt(index); return static_cast<QToolBarItem*>(item)->action; }
// XXX testing void rprint(size_t lvl) { for (size_t i = 0; i < lvl; i++) { printf(" "); } printf("[%u][%s][%d]\n", getPriority(), getCommitPath().to_string().c_str(), getCommitState()); for (size_t i = 0; i < numChildNodes(); i++) { childAt(i)->rprint(lvl + 1); } }
void TabBar::mouseDoubleClickEvent(QMouseEvent *event) { if (!childAt(event->pos()) // Remove the line below when QTabWidget does not have a one pixel frame && event->pos().y() < (y() + height())) { emit newTab(); return; } QTabBar::mouseDoubleClickEvent(event); }
int QgsSettingsTree::findChild( QTreeWidgetItem *parent, const QString &text, int startIndex ) { for ( int i = startIndex; i < childCount( parent ); ++i ) { if ( childAt( parent, i )->text( 0 ) == text ) return i; } return -1; }
void GestureWidget::mousePosition(int x, int y) { // On récupère le widget sous la position du curseur GestureButton *widget = (GestureButton*)childAt(x,y); // Si le widget est valide et que le pinceau n'est pas en mode dessin if (widget && *firstPoint) { // On récupère l'id du bouton cliqué QString id = widget->click(); // Si rouge, on change le pinceau, et on change de couleur le bouton // Idem pour les autres couleurs if (id == "red") { pen->setColor(QColor("#ff0000")); buttonColor->setStyleSheet("background-color: #ff0000"); } else if (id == "green") { pen->setColor(QColor("#00ff00")); buttonColor->setStyleSheet("background-color: #00ff00"); } else if (id == "blue") { pen->setColor(QColor("#0000ff")); buttonColor->setStyleSheet("background-color: #0000ff"); } else if (id == "black") { pen->setColor(QColor("#000000")); buttonColor->setStyleSheet("background-color: #000000"); } else if (id == "eraser") { pen->setColor(QColor("#ffffff")); buttonColor->setStyleSheet("background-color: #ffffff"); } // Si bouton "-" et que l'épaisseur > 1, on change l'épaisseur et MAJ du label // Idem pour "+" else if (id == "-" && pen->width() > 1) { pen->setWidth(pen->width() - 1); labelWidth->setText(QString::number(pen->width())); } else if (id == "+") { if (pen->width() < 20) { pen->setWidth(pen->width() + 1); labelWidth->setText(QString::number(pen->width())); } } } }
void InfoWidget::Implementation::mousePressEvent(QMouseEvent* event) { #ifdef EMBEDDED_LEFT_BUTTON_CONTEXT_MENU if(childAt(event->pos()) == ui.coverArtLabel) { m_coverArtMenu->popup(event->globalPos()); } #else Q_UNUSED(event); #endif }
void SecondaryWindow::mousePressEvent(QMouseEvent* event) { if (firstClicked == NULL) { firstClicked = childAt(event->x(), event->y()); if (firstClicked == ui->topBar) { dragClickX = event->x(); dragClickY = event->y(); } } }
bool TabButton::eventFilter(QObject *obj, QEvent *e){ bool ret = QPushButton::eventFilter(obj, e); if (e->type() == QEvent::MouseButtonRelease){ QMouseEvent *m_e = reinterpret_cast<QMouseEvent*>(e); if ((m_e->button() == Qt::MidButton) || (childAt(m_e->pos()) == static_cast<QWidget*>(label))) emit closeRequest(); } return ret; }
void MarbleLineEdit::mouseReleaseEvent( QMouseEvent* e ) { if ( d->m_clearButton == childAt( e->pos() ) ) { QString newText; if ( e->button() == Qt::MidButton ) { newText = QApplication::clipboard()->text( QClipboard::Selection ); setText( newText ); } else { setSelection( 0, text().size() ); del(); emit clearButtonClicked(); } emit textChanged( newText ); } if ( d->m_decoratorButton == childAt( e->pos() ) ) { emit decoratorButtonClicked(); } QLineEdit::mouseReleaseEvent( e ); }
CopasiSlider* SliderDialog::findCopasiSliderAtPosition(const QPoint& p) { QWidget* pWidget = childAt(p); CopasiSlider* pSlider = NULL; while (pWidget && pWidget != this && !pSlider) { pSlider = dynamic_cast<CopasiSlider*>(pWidget); pWidget = (QWidget*)pWidget->parent(); } return pSlider; }