本文整理汇总了C++中QMouseEvent::y方法的典型用法代码示例。如果您正苦于以下问题:C++ QMouseEvent::y方法的具体用法?C++ QMouseEvent::y怎么用?C++ QMouseEvent::y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMouseEvent
的用法示例。
在下文中一共展示了QMouseEvent::y方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool Row::eventFilter(QObject * obj, QEvent * ev) {
if (obj == sideWidget && ev->type() == QEvent::MouseButtonPress) {
QMouseEvent * e = static_cast<QMouseEvent *>(ev);
mousePressed(e->x(), e->y());
}
if (obj == this && ev->type() == QEvent::MouseButtonPress) {
QMouseEvent * e = static_cast<QMouseEvent *>(ev);
mousePressed(e->x(), e->y());
}
if ((obj == this) && (ev->type() == QEvent::Paint)) {
QPaintEvent * e = static_cast<QPaintEvent *>(ev);
paint(e->rect());
}
if ((obj == this) && (ev->type() == QEvent::Resize)) {
QResizeEvent * e = static_cast<QResizeEvent *>(ev);
this->pixPerMs = (double) e->size().width() / (double) (globalStopTime - globalStartTime);
qDebug() << pixPerMs;
repaint();
}
return true;
}
示例2: eventFilter
bool PersonalChatDlg::eventFilter(QObject *obj, QEvent *event)
{
if(obj == ui->btn_min){ //最小化、最大化、关闭按钮换图
if(event->type() == QEvent::Enter){
ui->btn_min->setPixmap(QPixmap(":/pixmap/image/miniButton-hover.png"));
}else if(event->type() == QEvent::Leave){
ui->btn_min->setPixmap(QPixmap(":/pixmap/image/miniButton.png"));
}else if(event->type() == QEvent::MouseButtonPress){
ui->btn_min->setPixmap(QPixmap(":/pixmap/image/miniButton-hover.png"));
}else if(event->type() == QEvent::MouseButtonRelease){
QMouseEvent *me = (QMouseEvent *)event;
QLabel *lb = (QLabel *)obj;
if(me->x() > 0 && me->x() < lb->width() && me->y() > 0 && me->y() < lb->height()){
this->showMinimized();
}else{
ui->btn_min->setPixmap(QPixmap(":/pixmap/image/miniButton.png"));
}
} else {
return QObject::eventFilter(obj, event);
}
}
if(obj == ui->btn_close){ //最小化、最大化、关闭按钮换图
if(event->type() == QEvent::Enter){
ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeButton-hover.png"));
}else if(event->type() == QEvent::Leave){
ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeButton.png"));
}else if(event->type() == QEvent::MouseButtonPress){
ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeButton-hover.png"));
}else if(event->type() == QEvent::MouseButtonRelease){
QMouseEvent *me = (QMouseEvent *)event;
QLabel *lb = (QLabel *)obj;
if(me->x() > 0 && me->x() < lb->width() && me->y() > 0 && me->y() < lb->height()){
this->close();
emit closePersonalchatdlg(bareJid);
}else{
ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeButton.png"));
}
} else {
return QObject::eventFilter(obj, event);
}
}
if(obj==ui->closeButton||obj==ui->sendMessageButton
||obj==ui->sendfileButton
||obj==ui->saveFileButton
||obj==ui->refuseButton)
{
if(event->type() == QEvent::MouseButtonPress)
{
QMouseEvent *me = (QMouseEvent *)event;
dragPos = me->globalPos() - frameGeometry().topLeft();
}else if(event->type() == QEvent::MouseButtonRelease)
{
setWindowOpacity(1);
}
}
return QObject::eventFilter(obj, event);
}
示例3: event
bool VncView::event(QEvent *event)
{
QMouseEvent *ev = static_cast<QMouseEvent*>(event);
QKeyEvent *ek = static_cast<QKeyEvent*>(event);
QWheelEvent *ew = static_cast<QWheelEvent*>(event);
switch (event->type()) {
case QEvent::KeyPress:
case QEvent::KeyRelease:
// kDebug(5011) << "keyEvent";
if ( ek!=Q_NULLPTR ) keyEventHandler(ek);
return true;
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
emit mouseClickedInto();
if ( ev!=Q_NULLPTR ) mouseEventHandler(ev);
return true;
case QEvent::MouseMove:
// kDebug(5011) << "mouseEvent";
if ( 0<=ev->y() && ev->y()<= 3 )
emit boarderTouched();
mouseEventHandler(ev);
return true;
case QEvent::Wheel:
// kDebug(5011) << "wheelEvent";
if ( ew!=Q_NULLPTR ) wheelEventHandler(ew);
return true;
default:
return RemoteView::event(event);
}
}
示例4: editorEvent
bool ButtonDelegate::editorEvent(QEvent *event, QAbstractItemModel *, const QStyleOptionViewItem &option, const QModelIndex &index)
{
QRect rect = option.rect;
QRect rectBu(rect.left() + rect.width()/2 - 15,
rect.top() + rect.height()/2 - 5,
30, 15);
if (event->type() == QEvent::MouseMove) {
QMouseEvent* e =(QMouseEvent*)event;
if (rectBu.contains(e->x(), e->y())) {
}
}
if (event->type() == QEvent::MouseButtonRelease) {
QMouseEvent* e =(QMouseEvent*)event;
if (rectBu.contains(e->x(), e->y())) {
int row = index.row();
emit currentRow(row);
return true;
}
}
return false;
}
示例5: eventFilter
bool MouseMove::eventFilter(QObject *widget, QEvent *e) {
if (e->type() == QEvent::MouseButtonPress) {
x = ((QMouseEvent *) e)->x();
y = ((QMouseEvent *) e)->y();
return true;
}
if (e->type() == QEvent::MouseMove) {
QMouseEvent *qMouseEv = (QMouseEvent *) e;
GlMainWidget *glMainWidget = (GlMainWidget *) widget;
if (qMouseEv->x() != x)
glMainWidget->getScene()->translateCamera(qMouseEv->x()-x,0,0);
if (qMouseEv->y() != y)
glMainWidget->getScene()->translateCamera(0,y-qMouseEv->y(),0);
x = qMouseEv->x();
y = qMouseEv->y();
glMainWidget->draw(false);
return true;
}
return false;
}
示例6: eventFilter
bool KFontDialog::eventFilter(QObject *obj, QEvent *event) {
if(obj == ui->btn_close) {
if(event->type() == QEvent::Enter){
ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn-hover.png"));
}else if(event->type() == QEvent::Leave){
ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn.png"));
}else if(event->type() == QEvent::MouseButtonPress){
ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn-hover.png"));
}else if(event->type() == QEvent::MouseButtonRelease){
QMouseEvent *me = (QMouseEvent *)event;
QLabel *lb = (QLabel *)obj;
if(me->x() > 0 && me->x() < lb->width() && me->y() > 0 && me->y() < lb->height()){
this->close();
}else{
ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn.png"));
}
} else {
return QObject::eventFilter(obj, event);
}
}
if(obj == ui->okBtn ||obj == ui->quitBtn)
{
if(event->type() == QEvent::MouseButtonPress)
{
QMouseEvent *me = (QMouseEvent *)event;
dragPos = me->globalPos() - frameGeometry().topLeft();
}else if(event->type() == QEvent::MouseButtonRelease)
{
setWindowOpacity(1);
}
}
return QObject::eventFilter(obj, event);
}
示例7: OnMouseMotion
void Camera::OnMouseMotion(const QMouseEvent & event)
{
_theta -= (event.x() - initialCursorPositionX ) *_sensivity;
_phi -= (event.y() - initialCursorPositionY ) *_sensivity;
initialCursorPositionX = event.x();
initialCursorPositionY = event.y();
VectorsFromAngles();
}
示例8: rect
void
KdmThemer::widgetEvent( QEvent *e )
{
if (!rootItem)
return;
switch (e->type()) {
case QEvent::MouseMove:
{
QMouseEvent *me = static_cast<QMouseEvent *>(e);
rootItem->mouseEvent( me->x(), me->y() );
}
break;
case QEvent::MouseButtonPress:
{
QMouseEvent *me = static_cast<QMouseEvent *>(e);
rootItem->mouseEvent( me->x(), me->y(), true );
}
break;
case QEvent::MouseButtonRelease:
{
QMouseEvent *me = static_cast<QMouseEvent *>(e);
rootItem->mouseEvent( me->x(), me->y(), false, true );
}
break;
case QEvent::Resize:
m_geometryOutdated = true;
widget()->update();
break;
case QEvent::Paint:
if (m_geometryOutdated) {
debug() << "==== updating geometry ====" << endl;
QStack<QSize> ps;
QRect rect( QPoint( 0, 0 ), widget()->size() );
rootItem->setGeometry( ps, rect, m_geometryInvalid );
if (debugLevel & DEBUG_THEMING)
showStructure();
m_geometryOutdated = m_geometryInvalid = false;
}
{
QRect paintRect = static_cast<QPaintEvent *>(e)->rect();
//kDebug() << "paint on: " << paintRect;
QPainter p( widget() );
rootItem->paint( &p, paintRect );
rootItem->showWidget();
}
break;
default:
break;
}
}
示例9: eventFilter
bool ParallelCoordsAxisBoxPlot::eventFilter(QObject *widget, QEvent *e) {
GlMainWidget *glWidget = dynamic_cast<GlMainWidget *>(widget);
if(!glWidget)
return false;
initOrUpdateBoxPlots();
if (e->type() == QEvent::MouseMove) {
QMouseEvent *me = (QMouseEvent *) e;
int x = glWidget->width() - me->x();
int y = me->y();
Coord screenCoords(x, y, 0.0f);
Coord sceneCoords(glWidget->getScene()->getLayer("Main")->getCamera().viewportTo3DWorld(glWidget->screenToViewport(screenCoords)));
selectedAxis = parallelView->getAxisUnderPointer(me->x(), me->y());
if (selectedAxis != NULL && dynamic_cast<QuantitativeParallelAxis *>(selectedAxis)) {
if (axisBoxPlotMap.find(static_cast<QuantitativeParallelAxis *>(selectedAxis)) != axisBoxPlotMap.end())
if (parallelView->getLayoutType() == ParallelCoordinatesDrawing::CIRCULAR) {
rotateVector(sceneCoords, -(selectedAxis->getRotationAngle()), Z_ROT);
}
axisBoxPlotMap[static_cast<QuantitativeParallelAxis *>(selectedAxis)]->setHighlightRangeIfAny(sceneCoords);
}
parallelView->refresh();
return true;
}
if (e->type() == QEvent::MouseButtonPress) {
return false;
}
if (e->type() == QEvent::MouseButtonRelease) {
if (selectedAxis != NULL && dynamic_cast<QuantitativeParallelAxis *>(selectedAxis)) {
Observable::holdObservers();
if (axisBoxPlotMap.find(static_cast<QuantitativeParallelAxis *>(selectedAxis)) != axisBoxPlotMap.end())
parallelView->highlightDataInAxisBoxPlotRange(static_cast<QuantitativeParallelAxis *>(selectedAxis));
Observable::unholdObservers();
selectedAxis = NULL;
parallelView->refresh();
return true;
}
}
return false;
}
示例10: eventFilter
bool Renderer::eventFilter(QObject *object, QEvent *event) {
if (object == image_label_ && event->type() == QEvent::MouseButtonPress) {
QMouseEvent *keyEvent = static_cast<QMouseEvent*>(event);
if (keyEvent->button() == Qt::LeftButton && print_zp_) {
// Sets the fixed frequency of the zoneplate to the corresponding
// frequency of the click location
double dist = sqrt(keyEvent->x()*keyEvent->x() + keyEvent->y()*keyEvent->y());
dist = zone_plate_.Size() * dist / std::max(Height(), Width());
freq_spin_->setValue(dist);
return true;
} else
return false;
}
return false;
}
示例11: eventFilter
bool TopBar::eventFilter(QObject *object, QEvent *event) {
if(object == ui->buttonIcon) {
if(event->type() == QEvent::MouseButtonPress) {
canMoveTopbar = true;
QMouseEvent *e = (QMouseEvent *)event;
pressedMouseX = e->x();
pressedMouseY = e->y();
event->accept();
} else if (event->type() == QEvent::MouseMove) {
if(canMoveTopbar) {
QMouseEvent *e = (QMouseEvent *)event;
ui->buttonIcon->setCursor(Qt::ClosedHandCursor);
move(e->globalX() - pressedMouseX, e->globalY() - pressedMouseY);
}
} else if(event->type() == QEvent::MouseButtonRelease) {
canMoveTopbar = false;
ui->buttonIcon->setCursor(Qt::OpenHandCursor);
event->accept();
} else if(event->type() == QEvent::Enter) {
ui->buttonIcon->setCursor(Qt::OpenHandCursor);
}
}
return QObject::eventFilter(object, event);
}
示例12: eventMouse
void PWidget::eventMouse(QObject *, QEvent *e)
{
PukeMessage pm;
widgetId wI;
QMouseEvent *me = Q_MOUSE_EVENT(e);
wI = widgetIden();
pm.iCommand = - e->type() - 1020; // 1020 offset for events
pm.iWinId = wI.iWinId;
pm.iArg = 0;
// special cArg handling
pm.iTextSize = 4*sizeof(int);
int *icArg = new int[4];
icArg[0] = me->x();
icArg[1] = me->y();
icArg[2] = me->button();
icArg[3] = me->state();
pm.cArg = (char *) icArg;
emit outputMessage(wI.fd, &pm);
delete[] icArg;
}
示例13: event
bool GameWindow::event(QEvent *event)
{
QMouseEvent *mouseEvent;
float deltaX = this->width() * 0.5f;
float deltaY = this->height() * 0.5f;
switch (event->type())
{
case QEvent::MouseMove:
if(cursorCaptured) {
mouseEvent = static_cast<QMouseEvent*>(event);
camera->rotate(-(deltaY - mouseEvent->y()) * 0.1f,
0,
-(deltaX - mouseEvent->x()) * 0.1f
);
}
return true;
case QEvent::MouseButtonPress:
this->setCursor(*cursor);
cursorCaptured = true;
return true;
case QEvent::UpdateRequest:
renderNow();
return true;
default:
return QWindow::event(event);
}
}
示例14: x
MouseEvent::MouseEvent(const QMouseEvent& event, const unsigned int deviceID) :
x(event.x()),
y(event.y()),
deviceID(deviceID),
isLeftButton(event.buttons().testFlag(Qt::LeftButton)),
isRightButton(event.buttons().testFlag(Qt::RightButton)),
isMiddleButton(event.buttons().testFlag(Qt::MiddleButton)),
isShifted(event.modifiers().testFlag(Qt::ShiftModifier)),
isControl(event.modifiers().testFlag(Qt::ControlModifier)),
isMeta(event.modifiers().testFlag(Qt::MetaModifier)),
isAlt(event.modifiers().testFlag(Qt::AltModifier))
{
// single button that caused the event
switch (event.button()) {
case Qt::LeftButton:
button = "LEFT";
isLeftButton = true;
break;
case Qt::RightButton:
button = "RIGHT";
isRightButton = true;
break;
case Qt::MiddleButton:
button = "MIDDLE";
isMiddleButton = true;
break;
default:
button = "NONE";
break;
}
}
示例15: editorEvent
bool NodeTableDelegate::editorEvent ( QEvent* event,
QAbstractItemModel* model,
const QStyleOptionViewItem& option,
const QModelIndex& index )
{
if ( index.column() != 2 )
return false;
QMouseEvent *mouseEvent;
if ( event->type() == QEvent::MouseButtonRelease ) {
mouseEvent = static_cast<QMouseEvent*>( event );
QRect checkBoxRect1 = getCheckBoxDrawArea( option );
QRect checkBoxRect2 = getCheckBoxDrawArea( option, false );
if ( checkBoxRect1.contains( mouseEvent->x(), mouseEvent->y() ) )
{
bool xCheckState, yCheckState;
getCheckStates( xCheckState, yCheckState, index );
Node::Fixation fixType =
getFixationByCheckStates( ! xCheckState, yCheckState );
QVariant fixation;
qVariantSetValue<Node::Fixation>( fixation, fixType );
model->setData( index, fixation );
emit cellWasChanged( index.row(), index.column() );
}
else if ( checkBoxRect2.contains( mouseEvent->x(), mouseEvent->y() ) )
{
bool xCheckState, yCheckState;
getCheckStates( xCheckState, yCheckState, index );
Node::Fixation fixType =
getFixationByCheckStates( xCheckState, ! yCheckState );
QVariant fixation;
qVariantSetValue<Node::Fixation>( fixation, fixType );
model->setData( index, fixation );
emit cellWasChanged( index.row(), index.column() );
}
}
return true;
}