本文整理汇总了C++中QPoint::x方法的典型用法代码示例。如果您正苦于以下问题:C++ QPoint::x方法的具体用法?C++ QPoint::x怎么用?C++ QPoint::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPoint
的用法示例。
在下文中一共展示了QPoint::x方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertToolbar
void QUnifiedToolbarSurface::insertToolbar(QWidget *toolbar, const QPoint &offset)
{
setGeometry(QRect(QPoint(0, 0), QSize(offset.x() + toolbar->width(), 100))); // FIXME
recursiveRedirect(toolbar, toolbar, offset);
}
示例2: renderControllerPointers
void ApplicationOverlay::renderControllerPointers() {
Application* application = Application::getInstance();
GLCanvas* glWidget = application->getGLWidget();
MyAvatar* myAvatar = application->getAvatar();
//Static variables used for storing controller state
static quint64 pressedTime[NUMBER_OF_RETICLES] = { 0ULL, 0ULL, 0ULL };
static bool isPressed[NUMBER_OF_RETICLES] = { false, false, false };
static bool stateWhenPressed[NUMBER_OF_RETICLES] = { false, false, false };
const HandData* handData = Application::getInstance()->getAvatar()->getHandData();
for (unsigned int palmIndex = 2; palmIndex < 4; palmIndex++) {
const int index = palmIndex - 1;
const PalmData* palmData = NULL;
if (palmIndex >= handData->getPalms().size()) {
return;
}
if (handData->getPalms()[palmIndex].isActive()) {
palmData = &handData->getPalms()[palmIndex];
} else {
continue;
}
int controllerButtons = palmData->getControllerButtons();
//Check for if we should toggle or drag the magnification window
if (controllerButtons & BUTTON_3) {
if (isPressed[index] == false) {
//We are now dragging the window
isPressed[index] = true;
//set the pressed time in us
pressedTime[index] = usecTimestampNow();
stateWhenPressed[index] = _magActive[index];
}
} else if (isPressed[index]) {
isPressed[index] = false;
//If the button was only pressed for < 250 ms
//then disable it.
const int MAX_BUTTON_PRESS_TIME = 250 * MSECS_TO_USECS;
if (usecTimestampNow() < pressedTime[index] + MAX_BUTTON_PRESS_TIME) {
_magActive[index] = !stateWhenPressed[index];
}
}
//if we have the oculus, we should make the cursor smaller since it will be
//magnified
if (OculusManager::isConnected()) {
QPoint point = getPalmClickLocation(palmData);
_reticlePosition[index] = point;
//When button 2 is pressed we drag the mag window
if (isPressed[index]) {
_magActive[index] = true;
}
// If oculus is enabled, we draw the crosshairs later
continue;
}
int mouseX, mouseY;
if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLasers)) {
QPoint res = getPalmClickLocation(palmData);
mouseX = res.x();
mouseY = res.y();
} else {
// Get directon relative to avatar orientation
glm::vec3 direction = glm::inverse(myAvatar->getOrientation()) * palmData->getFingerDirection();
// Get the angles, scaled between (-0.5,0.5)
float xAngle = (atan2(direction.z, direction.x) + M_PI_2);
float yAngle = 0.5f - ((atan2(direction.z, direction.y) + M_PI_2));
// Get the pixel range over which the xAngle and yAngle are scaled
float cursorRange = glWidget->width() * SixenseManager::getInstance().getCursorPixelRangeMult();
mouseX = (glWidget->width() / 2.0f + cursorRange * xAngle);
mouseY = (glWidget->height() / 2.0f + cursorRange * yAngle);
}
//If the cursor is out of the screen then don't render it
if (mouseX < 0 || mouseX >= glWidget->width() || mouseY < 0 || mouseY >= glWidget->height()) {
_reticleActive[index] = false;
continue;
}
_reticleActive[index] = true;
const float reticleSize = 40.0f;
mouseX -= reticleSize / 2.0f;
mouseY += reticleSize / 2.0f;
glBegin(GL_QUADS);
//.........这里部分代码省略.........
示例3: cutPoint
static QPoint cutPoint(QPoint p11, QPoint p12, QPoint p21, QPoint p22)
{
double dx1 = p12.x() - p11.x();
double dy1 = p12.y() - p11.y();
double dx2 = p22.x() - p21.x();
double dy2 = p22.y() - p21.y();
if ( dx1 == 0.0 && dx2 == 0.0 )
return QPoint();
if ( dx1 == 0.0 )
{
const double m = dy2 / dx2;
const double t = p21.y() - m * p21.x();
return QPoint(p11.x(), qwtInt(m * p11.x() + t));
}
if ( dx2 == 0 )
{
const double m = dy1 / dx1;
const double t = p11.y() - m * p11.x();
return QPoint(p21.x(), qwtInt(m * p21.x() + t));
}
const double m1 = dy1 / dx1;
const double t1 = p11.y() - m1 * p11.x();
const double m2 = dy2 / dx2;
const double t2 = p21.y() - m2 * p21.x();
if ( m1 == m2 )
return QPoint();
const double x = ( t2 - t1 ) / ( m1 - m2 );
const double y = t1 + m1 * x;
return QPoint(qwtInt(x), qwtInt(y));
}
示例4: mouseMoveEvent
void mouseMoveEvent(QMouseEvent *e) {
QPoint diff = e->pos() - mousePos;
mousePos = e->pos();
verticalScrollBar()->setValue(verticalScrollBar()->value() + diff.y());
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + diff.x());
}
示例5: InRect
bool TMOGUIToneSlider::InRect(const QPoint& p, int x1, int x2, int y1, int y2)
{
return (p.x() >= x1)&&(p.x() <= x2)&&(p.y() >= y1)&&(p.y() <= y2);
}
示例6: editorEvent
bool PluginItemDelegate::editorEvent( QEvent *event,
QAbstractItemModel *model,
const QStyleOptionViewItem &option,
const QModelIndex &index )
{
Q_ASSERT(event);
Q_ASSERT(model);
if ( ( event->type() == QEvent::MouseButtonRelease )
|| ( event->type() == QEvent::MouseButtonDblClick )
|| ( event->type() == QEvent::MouseButtonPress )
|| ( event->type() == QEvent::MouseMove ) )
{
QMouseEvent *me = static_cast<QMouseEvent*>(event);
QPoint mousePosition = me->pos() - option.rect.topLeft();
if ( ( event->type() == QEvent::MouseMove )
&& !( me->buttons() & Qt::LeftButton ) )
{
// If the mouse moves around and no left button is pressed, no pushbutton is pressed
// and no other event will be successful.
m_aboutPressedIndex = QModelIndex();
m_configPressedIndex = QModelIndex();
return true;
}
// Handle checkbox
QRect checkRect = checkboxOption( option, index, 0, Qt::AlignLeft ).rect;
if ( checkRect.contains( mousePosition )
&& ( ( event->type() == QEvent::MouseButtonDblClick )
|| ( event->type() == QEvent::MouseButtonRelease ) ) )
{
// make sure that the item is checkable
Qt::ItemFlags flags = model->flags(index);
if ( !( flags & Qt::ItemIsUserCheckable ) || !( option.state & QStyle::State_Enabled )
|| !( flags & Qt::ItemIsEnabled ) )
return false;
// make sure that we have a check state
QVariant checkValue = index.data( Qt::CheckStateRole );
if ( !checkValue.isValid() )
return false;
// eat the double click events inside the check rect
if ( event->type() == QEvent::MouseButtonDblClick )
return true;
Qt::CheckState state = ( static_cast<Qt::CheckState>( checkValue.toInt() ) == Qt::Checked
? Qt::Unchecked : Qt::Checked );
return model->setData(index, state, Qt::CheckStateRole);
}
if ( ( event->type() == QEvent::MouseMove )
&& !( me->buttons() & Qt::LeftButton ) )
{
m_aboutPressedIndex = QModelIndex();
m_configPressedIndex = QModelIndex();
return true;
}
QPoint topRight = option.rect.topRight();
// Handle aboutButton
{
QRect aboutRect = buttonOption( option,
index,
PluginItemDelegate::About,
topRight.x(),
Qt::AlignRight ).rect;
if ( aboutRect.contains( mousePosition ) ) {
if ( event->type() == QEvent::MouseButtonDblClick )
return true;
if ( event->type() == QEvent::MouseButtonPress ) {
m_aboutPressedIndex = index;
m_configPressedIndex = QModelIndex();
return true;
}
if ( event->type() == QEvent::MouseButtonRelease ) {
m_aboutPressedIndex = QModelIndex();
m_configPressedIndex = QModelIndex();
emit aboutPluginClicked( index );
return true;
}
if ( event->type() == QEvent::MouseMove ) {
if ( me->buttons() & Qt::LeftButton ) {
m_aboutPressedIndex = index;
m_configPressedIndex = QModelIndex();
return true;
}
else {
m_aboutPressedIndex = QModelIndex();
m_configPressedIndex = QModelIndex();
return true;
}
}
}
else {
// If the mouse is on the item and the mouse isn't above the button.
// no about button is pressed.
m_aboutPressedIndex = QModelIndex();
//.........这里部分代码省略.........
示例7: DoClientToScreen
void wxWindowQt::DoClientToScreen( int *x, int *y ) const
{
QPoint screenPosition = GetHandle()->mapToGlobal( QPoint( *x, *y ));
*x = screenPosition.x();
*y = screenPosition.y();
}
示例8: mouseMoveEvent
void note::mouseMoveEvent(QMouseEvent *event)//重写鼠标移动事件
{
QPoint gloPoint = event->globalPos();
QRect rect = this->rect();
QPoint tl = mapToGlobal(rect.topLeft());
QPoint rb = mapToGlobal(rect.bottomRight());
if(!isLeftPressDown) {
this->region(gloPoint);
} else {
if(dir != NONE) {
QRect rMove(tl, rb);
switch(dir) {
case LEFT:
if(rb.x() - gloPoint.x() <= this->minimumWidth())
rMove.setX(tl.x());
else
rMove.setX(gloPoint.x());
break;
case RIGHT:
rMove.setWidth(gloPoint.x() - tl.x());
break;
case UP:
if(rb.y() - gloPoint.y() <= this->minimumHeight())
rMove.setY(tl.y());
else
rMove.setY(gloPoint.y());
break;
case DOWN:
rMove.setHeight(gloPoint.y() - tl.y());
break;
case LEFTTOP:
if(rb.x() - gloPoint.x() <= this->minimumWidth())
rMove.setX(tl.x());
else
rMove.setX(gloPoint.x());
if(rb.y() - gloPoint.y() <= this->minimumHeight())
rMove.setY(tl.y());
else
rMove.setY(gloPoint.y());
break;
case RIGHTTOP:
rMove.setWidth(gloPoint.x() - tl.x());
rMove.setY(gloPoint.y());
break;
case LEFTBOTTOM:
rMove.setX(gloPoint.x());
rMove.setHeight(gloPoint.y() - tl.y());
break;
case RIGHTBOTTOM:
rMove.setWidth(gloPoint.x() - tl.x());
rMove.setHeight(gloPoint.y() - tl.y());
break;
default:
break;
}
this->setGeometry(rMove);
} else {
move(event->globalPos() - dragPosition);
event->accept();
}
}
QDialog::mouseMoveEvent(event);
}
示例9: TileLayer
TileLayer::TileLayer(const QString &name, QPoint position, QSize size)
: TileLayer(name, position.x(), position.y(), size.width(), size.height())
{
}
示例10: limitToScreen
void QWSMouseHandler::limitToScreen(QPoint &position)
{
position.setX(qMin(d_ptr->screen->deviceWidth() - 1, qMax(0, position.x())));
position.setY(qMin(d_ptr->screen->deviceHeight() - 1, qMax(0, position.y())));
}
示例11: region
void note::region(const QPoint &cursorGlobalPoint)//改变大小时,位置计算
{
QRect rect = this->rect();
QPoint tl = mapToGlobal(rect.topLeft());
QPoint rb = mapToGlobal(rect.bottomRight());
int x = cursorGlobalPoint.x();
int y = cursorGlobalPoint.y();
if(tl.x() + PADDING >= x && tl.x() <= x && tl.y() + PADDING >= y && tl.y() <= y) {
// 左上角
dir = LEFTTOP;
this->setCursor(QCursor(Qt::SizeFDiagCursor));
} else if(x >= rb.x() - PADDING && x <= rb.x() && y >= rb.y() - PADDING && y <= rb.y()) {
// 右下角
dir = RIGHTBOTTOM;
this->setCursor(QCursor(Qt::SizeFDiagCursor));
} else if(x <= tl.x() + PADDING && x >= tl.x() && y >= rb.y() - PADDING && y <= rb.y()) {
//左下角
dir = LEFTBOTTOM;
this->setCursor(QCursor(Qt::SizeBDiagCursor));
} else if(x <= rb.x() && x >= rb.x() - PADDING && y >= tl.y() && y <= tl.y() + PADDING) {
// 右上角
dir = RIGHTTOP;
this->setCursor(QCursor(Qt::SizeBDiagCursor));
} else if(x <= tl.x() + PADDING && x >= tl.x()) {
// 左边
dir = LEFT;
this->setCursor(QCursor(Qt::SizeHorCursor));
} else if( x <= rb.x() && x >= rb.x() - PADDING) {
// 右边
dir = RIGHT;
this->setCursor(QCursor(Qt::SizeHorCursor));
}else if(y >= tl.y() && y <= tl.y() + PADDING){
// 上边
dir = UP;
this->setCursor(QCursor(Qt::SizeVerCursor));
} else if(y <= rb.y() && y >= rb.y() - PADDING) {
// 下边
dir = DOWN;
this->setCursor(QCursor(Qt::SizeVerCursor));
}else {
// 默认
dir = NONE;
this->setCursor(QCursor(Qt::ArrowCursor));
}
}
示例12: updateGeometry
void VIfStatementCF::updateGeometry(int availableWidth, int availableHeight)
{
clearConnectors();
breaks_.clear();
continues_.clear();
if (!showAsControlFlow())
{
Item::updateGeometry(vis_, availableWidth, availableHeight);
return;
}
// First compute the size
int halfCondition = conditionBackground->width()/2 + style()->pinLength();
int leftHalf = halfCondition + thenBranch->entrance().x();
int rightHalf = halfCondition + elseBranch->width() - elseBranch->entrance().x();
int extraLeft = leftHalf - thenBranch->width() - style()->pinLength();
if (extraLeft < 0)
{
leftHalf += -extraLeft;
extraLeft = 0;
}
int extraRight = rightHalf - elseBranch->width() - style()->pinLength();
if (extraRight < 0)
{
rightHalf += -extraRight;
extraRight = 0;
}
int height = conditionBackground->height() + style()->pinLength();
int branchesTop = height;
height += ( thenBranch->height() > elseBranch->height() ) ? thenBranch->height() : elseBranch->height() ;
height += 3*style()->pinLength();
// Set the size
if ( hasShape() ) getShape()->setInnerSize(leftHalf + rightHalf, height);
else setSize(leftHalf + rightHalf, height);
// Set the positions
conditionBackground->setPos(leftHalf - conditionBackground->width()/2,style()->pinLength());
thenBranch->setPos(0, branchesTop);
elseBranch->setPos(leftHalf + extraRight + style()->pinLength(), branchesTop);
entrance_ = QPoint(leftHalf, 0);
// Put connectors
addConnector(leftHalf, 0, leftHalf, style()->pinLength(), true);
// Then
addConnector(conditionBackground->pos().x(), style()->pinLength() + conditionBackground->height()/2,
thenBranch->entrance().x(), style()->pinLength() + conditionBackground->height()/2, false);
addToLastConnector(thenBranch->pos().toPoint() + thenBranch->entrance());
// Else
addConnector(conditionBackground->pos().x() + conditionBackground->width(), style()->pinLength() + conditionBackground->height()/2,
elseBranch->pos().toPoint().x() + elseBranch->entrance().x(), style()->pinLength() + conditionBackground->height()/2, false);
addToLastConnector(elseBranch->pos().toPoint() + elseBranch->entrance());
// Process Connectors on the then branch
int thenBranchInnerBegin = height; // Height indicates no connectors on the inner side
for (int i = 0; i < thenBranch->breaks().size(); ++i)
{
QPoint p = thenBranch->breaks().at(i);
if (p.x() == 0) breaks_.append(thenBranch->pos().toPoint() + p);
else if (thenBranch->pos().y() + p.y() < thenBranchInnerBegin)
thenBranchInnerBegin = thenBranch->pos().y() + p.y();
}
for (int i = 0; i < thenBranch->continues().size(); ++i)
{
QPoint p = thenBranch->continues().at(i);
if (p.x() == 0) continues_.append(thenBranch->pos().toPoint() + p);
else if (thenBranch->pos().y() + p.y() < thenBranchInnerBegin)
thenBranchInnerBegin = thenBranch->pos().y() + p.y();
}
// Process Connectors on the else branch
int elseBranchInnerBegin = height; // Height indicates no connectors on the inner side
for (int i = 0; i < elseBranch->breaks().size(); ++i)
{
QPoint p = elseBranch->breaks().at(i);
if (p.x() > 0) breaks_.append(QPoint(1, elseBranch->pos().y() + p.y()));
else if (elseBranch->pos().y() + p.y() < elseBranchInnerBegin)
elseBranchInnerBegin = elseBranch->pos().y() + p.y();
}
for (int i = 0; i < elseBranch->continues().size(); ++i)
{
QPoint p = elseBranch->continues().at(i);
if (p.x() > 0) continues_.append(QPoint(1, elseBranch->pos().y() + p.y()));
else if (elseBranch->pos().y() + p.y() < elseBranchInnerBegin)
elseBranchInnerBegin = elseBranch->pos().y() + p.y();
}
// If there are any break or continue statements on the inside put the corresponding connectors
if (thenBranchInnerBegin < height)
{
addConnector(thenBranch->width(), thenBranchInnerBegin, thenBranch->width() , height - 3*style()->pinLength(), false);
addToLastConnector(width(), height - 3*style()->pinLength());
QPoint c = QPoint(1, height - 3*style()->pinLength());
//.........这里部分代码省略.........
示例13: paintEvent
void graph::paintEvent( QPaintEvent * )
{
QPainter p( this );
p.setPen( QPen( m_graphColor, 1 ) );
QVector<float> * samps = &(model()->m_samples);
int length = model()->length();
const float maxVal = model()->maxValue();
float xscale = (float)( width()-4 ) / length;
float yscale = (float)( height()-4 ) / ( model()->minValue() - maxVal );
// Max index, more useful below
length--;
switch( m_graphStyle )
{
case graph::LinearStyle:
p.setRenderHints( QPainter::Antialiasing, true );
for( int i=0; i < length; i++ )
{
// Needs to be rewritten
p.drawLine(2+static_cast<int>(i*xscale),
2+static_cast<int>( ( (*samps)[i] - maxVal ) * yscale ),
2+static_cast<int>((i+1)*xscale),
2+static_cast<int>( ( (*samps)[i+1] - maxVal ) * yscale )
);
}
// Draw last segment wrapped around
p.drawLine(2+static_cast<int>(length*xscale),
2+static_cast<int>( ( (*samps)[length] - maxVal ) * yscale ),
width()-2,
2+static_cast<int>( ( (*samps)[0] - maxVal ) * yscale ) );
p.setRenderHints( QPainter::Antialiasing, false );
break;
case graph::NearestStyle:
for( int i=0; i < length; i++ )
{
p.drawLine(2+static_cast<int>(i*xscale),
2+static_cast<int>( ( (*samps)[i] - maxVal ) * yscale ),
2+static_cast<int>((i+1)*xscale),
2+static_cast<int>( ( (*samps)[i] - maxVal ) * yscale )
);
p.drawLine(2+static_cast<int>((i+1)*xscale),
2+static_cast<int>( ( (*samps)[i] - maxVal ) * yscale ),
2+static_cast<int>((i+1)*xscale),
2+static_cast<int>( ( (*samps)[i+1] - maxVal ) * yscale )
);
}
p.drawLine(2+static_cast<int>(length*xscale),
2+static_cast<int>( ( (*samps)[length] - maxVal ) * yscale ),
width()-2,
2+static_cast<int>( ( (*samps)[length] - maxVal ) * yscale ) );
break;
default:
break;
}
// draw Pointer
if( m_mouseDown )
{
QPoint cursor = mapFromGlobal( QCursor::pos() );
p.setPen( QColor( 0xAA, 0xFF, 0x00, 0x70 ) );
p.drawLine( 2, cursor.y(), width()-2, cursor.y() );
p.drawLine( cursor.x(), 2, cursor.x(), height()-2 );
}
p.drawPixmap( 0, 0, m_foreground );
}
示例14: indexAtPoint
int StripChart::indexAtPoint(const QPoint& point) {
return (width() - point.x()) * _history->size() / width();
}
示例15: dist
double MyMoveServer::dist(const QPoint& p1, const QPoint& p2)
{
return qSqrt(qPow(p1.x()-p2.x(),2)+qPow(p1.y()-p2.y(),2));
}