本文整理汇总了C++中QRect::intersects方法的典型用法代码示例。如果您正苦于以下问题:C++ QRect::intersects方法的具体用法?C++ QRect::intersects怎么用?C++ QRect::intersects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRect
的用法示例。
在下文中一共展示了QRect::intersects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintEvent
void PanelKMenu::paintEvent(QPaintEvent * e)
{
if (sidePixmap.isNull()) {
PanelServiceMenu::paintEvent(e);
return;
}
QPainter p(this);
p.setClipRegion(e->region());
QStyleOptionFrame frOpt;
frOpt.init(this);
frOpt.lineWidth = frameWidth();
frOpt.midLineWidth = 0;
style()->drawPrimitive( QStyle::PE_FrameMenu, &frOpt, &p, this);
QRect r = sideImageRect();
r.setBottom( r.bottom() - sidePixmap.height() );
if ( r.intersects( e->rect() ) )
{
p.drawTiledPixmap( r, sideTilePixmap );
}
r = sideImageRect();
r.setTop( r.bottom() - sidePixmap.height() );
if ( r.intersects( e->rect() ) )
{
QRect drawRect = r.intersect( e->rect() );
QRect pixRect = drawRect;
pixRect.translate( -r.left(), -r.top() );
p.drawPixmap( drawRect.topLeft(), sidePixmap, pixRect );
}
PanelServiceMenu::paintEvent( e );
}
示例2: mousePressEvent
void ImagesCollectionView::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
for (int i = 0; i < 9; i++) {
QRect rect = images[i].frameGeometry();
QRect p = QRect(event->pos().x(),event->pos().y(),1,1);
if (rect.intersects(p)) {
images[i].setBeingSelected(true);
selectedIndexofImage = count - 9 + i;
cout << "press the left mouse button: select the button, index:"
<< selectedIndexofImage << endl;
}
else
images[i].setBeingSelected(false);
}
} else if (event->button() == Qt::RightButton) {
for (int i = 0; i < 9; i++) {
QRect rect = images[i].frameGeometry();
QRect p = QRect(event->pos().x(),event->pos().y(),1,1);
if (rect.intersects(p) && images[i].getBeingSelected()) {
images[i].setBeingSelected(false);
selectedIndexofImage = -1;
cout << "press the right mouse button: cancel the selected, index:"
<< selectedIndexofImage << endl;
}
}
}
}
示例3: paintEvent
void PanelKMenu::paintEvent(QPaintEvent * e)
{
if (sidePixmap.isNull()) {
PanelServiceMenu::paintEvent(e);
return;
}
QPainter p(this);
p.setClipRegion(e->region());
style().drawPrimitive( QStyle::PE_PanelPopup, &p,
QRect( 0, 0, width(), height() ),
colorGroup(), QStyle::Style_Default,
QStyleOption( frameWidth(), 0 ) );
QRect r = sideImageRect();
r.setBottom( r.bottom() - sidePixmap.height() );
if ( r.intersects( e->rect() ) )
{
p.drawTiledPixmap( r, sideTilePixmap );
}
r = sideImageRect();
r.setTop( r.bottom() - sidePixmap.height() );
if ( r.intersects( e->rect() ) )
{
QRect drawRect = r.intersect( e->rect() );
QRect pixRect = drawRect;
pixRect.moveBy( -r.left(), -r.top() );
p.drawPixmap( drawRect.topLeft(), sidePixmap, pixRect );
}
drawContents( &p );
}
示例4: moveShot
void CannonField::moveShot()
{
QRegion region = shotRect();
++timerCount;
QRect shotR = shotRect();
if (shotR.intersects(targetRect()))
{
autoShootTimer->stop();
emit hit();
emit canShoot(true);
}
else if (shotR.x() > width() || shotR.y() > height() || shotR.intersects(barrierRect()))
{
autoShootTimer->stop();
emit missed();
emit canShoot(true);
}
else
{
region = region.unite(shotR);
}
update(region);
}
示例5: paintEvent
void CannonField::paintEvent( QPaintEvent *e )
{
QRect updateR = e->rect();
QPainter p;
p.begin( this );
if ( updateR.intersects( cannonRect() ) )
paintCannon( &p );
if ( shooting && updateR.intersects( shotRect() ) )
paintShot( &p );
p.end();
}
示例6: paintEvent
void CannonField::paintEvent( QPaintEvent *e )
{
QRect updateR = e->rect();
QPainter p( this );
if ( updateR.intersects( cannonRect() ) )
paintCannon( &p );
if ( autoShootTimer->isActive() &&
updateR.intersects( shotRect() ) )
paintShot( &p );
if ( updateR.intersects( targetRect() ) )
paintTarget( &p );
}
示例7: p
void
PrettyPopupMenu::paintEvent( QPaintEvent* e )
{
generateSidePixmap();
QPainter p( this );
QRect r = sideImageRect();
r.setTop( r.bottom() - s_sidePixmap.height() );
if ( r.intersects( e->rect() ) )
{
QRect drawRect = r.intersect( e->rect() ).intersect( sideImageRect() );
QRect pixRect = drawRect;
pixRect.moveBy( -r.left(), -r.top() );
p.drawImage( drawRect.topLeft(), s_sidePixmap, pixRect );
}
p.setClipRegion( e->region() );
//NOTE The order is important here. drawContents() must be called before drawPrimitive(),
// otherwise we get rendering glitches.
drawContents( &p );
style().drawPrimitive( QStyle::PE_PanelPopup, &p,
QRect( 0, 0, width(), height() ),
colorGroup(), QStyle::Style_Default,
QStyleOption( frameWidth(), 0 ) );
}
示例8: select
void HTMLClue::select( KHTMLWidget *_htmlw, HTMLChain *_chain,
QRect & _rect, int _tx, int _ty )
{
HTMLObject *obj;
QRect r( x + _tx, y - ascent + _ty, width, ascent + descent );
_tx += x;
_ty += y - ascent;
_chain->push( this );
if ( _rect.contains( r ) )
{
for ( obj = head; obj != 0; obj = obj->next() )
obj->select( _htmlw, _chain, TRUE, _tx, _ty );
}
else if ( !_rect.intersects( r ) )
{
for ( obj = head; obj != 0; obj = obj->next() )
obj->select( _htmlw, _chain, FALSE, _tx, _ty );
}
else
{
for ( obj = head; obj != 0; obj = obj->next() )
obj->select( _htmlw, _chain, _rect, _tx, _ty );
}
_chain->pop();
}
示例9: isProbablyTotallyUnselected
bool KisPixelSelection::isProbablyTotallyUnselected(const QRect & r) const
{
if (*(m_datamanager->defaultPixel()) != MIN_SELECTED)
return false;
QRect sr = selectedRect();
return ! r.intersects(sr);
}
示例10: positionTip
void SizeTip::positionTip( const QRect &rect )
{
QRect tipRect = geometry();
tipRect.moveTopLeft( QPoint( 0, 0 ) );
if ( rect.intersects( tipRect ) )
{
QRect deskR = KGlobalSettings::desktopGeometry( QPoint( 0, 0 ) );
tipRect.moveCenter( QPoint( deskR.width()/2, deskR.height()/2 ) );
if ( !rect.contains( tipRect, true ) && rect.intersects( tipRect ) )
tipRect.moveBottomRight( geometry().bottomRight() );
}
move( tipRect.topLeft() );
}
示例11: state
QAccessible::State QAccessibleTableCell::state() const
{
QAccessible::State st;
QRect globalRect = view->rect();
globalRect.translate(view->mapToGlobal(QPoint(0,0)));
if (!globalRect.intersects(rect()))
st.invisible = true;
if (view->selectionModel()->isSelected(m_index))
st.selected = true;
if (view->selectionModel()->currentIndex() == m_index)
st.focused = true;
if (m_index.model()->data(m_index, Qt::CheckStateRole).toInt() == Qt::Checked)
st.checked = true;
Qt::ItemFlags flags = m_index.flags();
if (flags & Qt::ItemIsSelectable) {
st.selectable = true;
st.focusable = true;
if (view->selectionMode() == QAbstractItemView::MultiSelection)
st.multiSelectable = true;
if (view->selectionMode() == QAbstractItemView::ExtendedSelection)
st.extSelectable = true;
}
if (m_role == QAccessible::TreeItem) {
const QTreeView *treeView = qobject_cast<const QTreeView*>(view);
if (treeView->model()->hasChildren(m_index))
st.expandable = true;
if (treeView->isExpanded(m_index))
st.expanded = true;
}
return st;
}
示例12: isTotallyUnselected
bool KisPixelSelection::isTotallyUnselected(const QRect & r) const
{
if (*defaultPixel() != MIN_SELECTED)
return false;
QRect sr = selectedExactRect();
return ! r.intersects(sr);
}
示例13:
QAccessible::State QAccessibleTable2Cell::state(int child) const
{
Q_ASSERT(child == 0);
State st = Normal;
QRect globalRect = view->rect();
globalRect.translate(view->mapToGlobal(QPoint(0,0)));
if (!globalRect.intersects(rect(0)))
st |= Invisible;
if (view->selectionModel()->isSelected(m_index))
st |= Selected;
if (view->selectionModel()->currentIndex() == m_index)
st |= Focused;
if (m_index.model()->data(m_index, Qt::CheckStateRole).toInt() == Qt::Checked)
st |= Checked;
Qt::ItemFlags flags = m_index.flags();
if (flags & Qt::ItemIsSelectable) {
st |= Selectable;
st |= Focusable;
if (view->selectionMode() == QAbstractItemView::MultiSelection)
st |= MultiSelectable;
if (view->selectionMode() == QAbstractItemView::ExtendedSelection)
st |= ExtSelectable;
}
if (m_role == QAccessible::TreeItem) {
const QTreeView *treeView = qobject_cast<const QTreeView*>(view);
if (treeView->isExpanded(m_index))
st |= Expanded;
}
return st;
}
示例14: updateSelectedItem
/**
* @todo パフォーマンス悪いので改善する。
* 例えば、以下の改善策がある。
* (1) 矩形内にアイテムが一つもなかった場合は、特に何もしない
*/
void PianorollTrackView::updateSelectedItem() {
const VSQ_NS::Sequence *sequence = controllerAdapter->getSequence();
if (!sequence) {
return;
}
// 選択状態を最初の状態に戻す
ItemSelectionManager *manager = controllerAdapter->getItemSelectionManager();
manager->revertSelectionStatusTo(mouseStatus.itemSelectionStatusAtFirst);
// 矩形に入っているアイテムを、選択状態とする。
// ただし、矩形選択直前に選択状態となっているものは選択状態を解除する
QRect rect = mouseStatus.rect();
const VSQ_NS::Event::List *list = sequence->track(trackIndex)->events();
int count = list->size();
std::set<const VSQ_NS::Event *> add;
std::set<const VSQ_NS::Event *> remove;
for (int i = 0; i < count; i++) {
const VSQ_NS::Event *item = list->get(i);
if (item->type != VSQ_NS::EventType::NOTE) continue;
QRect itemRect = getNoteItemRect(item);
if (itemRect.right() < rect.left()) continue;
if (rect.right() < itemRect.left()) break;
if (rect.intersects(itemRect)) {
if (mouseStatus.itemSelectionStatusAtFirst.isContains(item)) {
remove.insert(item);
} else {
add.insert(item);
}
}
}
manager->add(add);
manager->remove(remove);
}
示例15: drawBackground
void TextDocument::drawBackground(QPainter* painter, const QRect& bounds)
{
if (d.highlights.isEmpty() && d.lowlight == -1)
return;
const int margin = qCeil(documentMargin());
const QAbstractTextDocumentLayout* layout = documentLayout();
static QPointer<TextLowlight> lowlightFrame = 0;
if (!lowlightFrame)
lowlightFrame = new TextLowlight(static_cast<QWidget*>(painter->device()));
static QPointer<TextHighlight> highlightFrame = 0;
if (!highlightFrame)
highlightFrame = new TextHighlight(static_cast<QWidget*>(painter->device()));
if (d.lowlight != -1) {
const QAbstractTextDocumentLayout* layout = documentLayout();
const int margin = qCeil(documentMargin());
const QTextBlock to = findBlockByNumber(d.lowlight);
if (to.isValid()) {
QRect br = layout->blockBoundingRect(to).toAlignedRect();
br.setTop(0);
if (bounds.intersects(br)) {
br.adjust(-margin - 1, 0, margin + 1, 2);
painter->translate(br.topLeft());
lowlightFrame->setGeometry(br);
lowlightFrame->render(painter);
painter->translate(-br.topLeft());
}
}
}
foreach (int highlight, d.highlights) {
QTextBlock block = findBlockByNumber(highlight);
if (block.isValid()) {
QRect br = layout->blockBoundingRect(block).toAlignedRect();
if (bounds.intersects(br)) {
br.adjust(-margin - 1, 0, margin + 1, 2);
painter->translate(br.topLeft());
highlightFrame->setGeometry(br);
highlightFrame->render(painter);
painter->translate(-br.topLeft());
}
}
}
}