本文整理汇总了C++中QCustomPlot::setCursor方法的典型用法代码示例。如果您正苦于以下问题:C++ QCustomPlot::setCursor方法的具体用法?C++ QCustomPlot::setCursor怎么用?C++ QCustomPlot::setCursor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCustomPlot
的用法示例。
在下文中一共展示了QCustomPlot::setCursor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseMoved
void SequenceDialog::mouseMoved(QMouseEvent *event)
{
QCustomPlot *sp = ui->sequencePlot;
Qt::CursorShape shape = Qt::ArrowCursor;
if (event) {
if (event->buttons().testFlag(Qt::LeftButton)) {
shape = Qt::ClosedHandCursor;
} else {
if (sp->axisRect()->rect().contains(event->pos())) {
shape = Qt::OpenHandCursor;
}
}
}
sp->setCursor(QCursor(shape));
packet_num_ = 0;
QString hint;
if (event) {
seq_analysis_item_t *sai = seq_diagram_->itemForPosY(event->pos().y());
if (sai) {
packet_num_ = sai->fd->num;
hint = QString("Packet %1: %2").arg(packet_num_).arg(sai->comment);
}
}
if (hint.isEmpty()) {
hint += tr("%Ln node(s)", "", seq_analysis_.num_nodes) + QString(", ")
+ tr("%Ln item(s)", "", num_items_);
}
hint.prepend("<small><i>");
hint.append("</i></small>");
ui->hintLabel->setText(hint);
}
示例2: diagramClicked
void SequenceDialog::diagramClicked(QMouseEvent *event)
{
QCustomPlot *sp = ui->sequencePlot;
if (event->button() == Qt::RightButton) {
// XXX We should find some way to get sequenceDiagram to handle a
// contextMenuEvent instead.
ctx_menu_.exec(event->globalPos());
} else if (sp->axisRect()->rect().contains(event->pos())) {
sp->setCursor(QCursor(Qt::ClosedHandCursor));
}
on_actionGoToPacket_triggered();
}
示例3: mouseReleased
void LteRlcGraphDialog::mouseReleased(QMouseEvent *event)
{
QCustomPlot *rp = ui->rlcPlot;
if (rubber_band_) {
rubber_band_->hide();
if (!mouse_drags_) {
QRectF zoom_ranges = getZoomRanges(QRect(rb_origin_, event->pos()));
if (zoom_ranges.width() > 0.0 && zoom_ranges.height() > 0.0) {
rp->xAxis->setRangeLower(zoom_ranges.x());
rp->xAxis->setRangeUpper(zoom_ranges.x() + zoom_ranges.width());
rp->yAxis->setRangeLower(zoom_ranges.y());
rp->yAxis->setRangeUpper(zoom_ranges.y() + zoom_ranges.height());
rp->replot();
}
}
} else if (rp->cursor().shape() == Qt::ClosedHandCursor) {
rp->setCursor(QCursor(Qt::OpenHandCursor));
}
}
示例4: graphClicked
void TCPStreamDialog::graphClicked(QMouseEvent *event)
{
QCustomPlot *sp = ui->streamPlot;
if (event->button() == Qt::RightButton) {
// XXX We should find some way to get streamPlot to handle a
// contextMenuEvent instead.
ctx_menu_.exec(event->globalPos());
} else if (mouse_drags_) {
if (sp->axisRect()->rect().contains(event->pos())) {
sp->setCursor(QCursor(Qt::ClosedHandCursor));
}
on_actionGoToPacket_triggered();
} else {
if (!rubber_band_) {
rubber_band_ = new QRubberBand(QRubberBand::Rectangle, sp);
}
rb_origin_ = event->pos();
rubber_band_->setGeometry(QRect(rb_origin_, QSize()));
rubber_band_->show();
}
}
示例5: mouseMoved
void LteRlcGraphDialog::mouseMoved(QMouseEvent *event)
{
QCustomPlot *rp = ui->rlcPlot;
Qt::CursorShape shape = Qt::ArrowCursor;
// Set the cursor shape.
if (event) {
if (event->buttons().testFlag(Qt::LeftButton)) {
if (mouse_drags_) {
shape = Qt::ClosedHandCursor;
} else {
shape = Qt::CrossCursor;
}
} else if (rp->axisRect()->rect().contains(event->pos())) {
if (mouse_drags_) {
shape = Qt::OpenHandCursor;
} else {
shape = Qt::CrossCursor;
}
}
rp->setCursor(QCursor(shape));
}
// Trying to let 'hint' grow efficiently. Still pretty slow for a dense graph...
QString hint;
hint.reserve(128);
hint = "<small><i>";
if (mouse_drags_) {
double tr_key = tracer_->position->key();
struct rlc_segment *packet_seg = NULL;
packet_num_ = 0;
// XXX If we have multiple packets with the same timestamp tr_key
// may not return the packet we want. It might be possible to fudge
// unique keys using nextafter().
if (event && tracer_->graph() && tracer_->position->axisRect()->rect().contains(event->pos())) {
packet_seg = time_stamp_map_.value(tr_key, NULL);
}
if (!packet_seg) {
tracer_->setVisible(false);
hint += "Hover over the graph for details. </i></small>";
ui->hintLabel->setText(hint);
ui->rlcPlot->replot(QCustomPlot::rpQueued);
return;
}
tracer_->setVisible(true);
packet_num_ = packet_seg->num;
hint += tr("%1 %2 (%3s seq %4 len %5)")
.arg(cap_file_.capFile() ? tr("Click to select packet") : tr("Packet"))
.arg(packet_num_)
.arg(QString::number(packet_seg->rel_secs + packet_seg->rel_usecs / 1000000.0, 'g', 4))
.arg(packet_seg->SN)
.arg(packet_seg->pduLength);
tracer_->setGraphKey(ui->rlcPlot->xAxis->pixelToCoord(event->pos().x()));
// Redrawing the whole graph is making the update *very* slow!
// TODO: Is there a way just to draw the parts that may have changed?
// In the GTK version, we displayed the stored pixbuf and draw temporary items on top...
rp->replot(QCustomPlot::rpQueued);
} else {
if (event && rubber_band_ && rubber_band_->isVisible()) {
rubber_band_->setGeometry(QRect(rb_origin_, event->pos()).normalized());
QRectF zoom_ranges = getZoomRanges(QRect(rb_origin_, event->pos()));
if (zoom_ranges.width() > 0.0 && zoom_ranges.height() > 0.0) {
hint += tr("Release to zoom, x = %1 to %2, y = %3 to %4")
.arg(zoom_ranges.x())
.arg(zoom_ranges.x() + zoom_ranges.width())
.arg(zoom_ranges.y())
.arg(zoom_ranges.y() + zoom_ranges.height());
} else {
hint += tr("Unable to select range.");
}
} else {
hint += tr("Click to select a portion of the graph.");
}
}
hint.append("</i></small>");
ui->hintLabel->setText(hint);
}
示例6: mouseMoved
// Setting mouseTracking on our streamPlot may not be as reliable
// as we need. If it's not we might want to poll the mouse position
// using a QTimer instead.
void TCPStreamDialog::mouseMoved(QMouseEvent *event)
{
QCustomPlot *sp = ui->streamPlot;
Qt::CursorShape shape = Qt::ArrowCursor;
if (event) {
if (event->buttons().testFlag(Qt::LeftButton)) {
if (mouse_drags_) {
shape = Qt::ClosedHandCursor;
} else {
shape = Qt::CrossCursor;
}
} else {
if (sp->axisRect()->rect().contains(event->pos())) {
if (mouse_drags_) {
shape = Qt::OpenHandCursor;
} else {
shape = Qt::CrossCursor;
}
}
}
}
sp->setCursor(QCursor(shape));
QString hint = "<small><i>";
if (mouse_drags_) {
double tr_key = tracer_->position->key();
struct segment *packet_seg = NULL;
packet_num_ = 0;
// XXX If we have multiple packets with the same timestamp tr_key
// may not return the packet we want. It might be possible to fudge
// unique keys using nextafter().
if (event && tracer_->graph() && tracer_->position->axisRect()->rect().contains(event->pos())) {
switch (graph_.type) {
case GRAPH_TSEQ_STEVENS:
case GRAPH_TSEQ_TCPTRACE:
case GRAPH_THROUGHPUT:
case GRAPH_WSCALE:
packet_seg = time_stamp_map_.value(tr_key, NULL);
break;
case GRAPH_RTT:
packet_seg = sequence_num_map_.value(tr_key, NULL);
default:
break;
}
}
if (!packet_seg) {
tracer_->setVisible(false);
hint += "Hover over the graph for details. " + stream_desc_ + "</i></small>";
ui->hintLabel->setText(hint);
ui->streamPlot->replot();
return;
}
tracer_->setVisible(true);
packet_num_ = packet_seg->num;
hint += tr("%1 %2 (%3s len %4 seq %5 ack %6 win %7)")
.arg(cap_file_ ? tr("Click to select packet") : tr("Packet"))
.arg(packet_num_)
.arg(QString::number(packet_seg->rel_secs + packet_seg->rel_usecs / 1000000.0, 'g', 4))
.arg(packet_seg->th_seglen)
.arg(packet_seg->th_seq)
.arg(packet_seg->th_ack)
.arg(packet_seg->th_win);
tracer_->setGraphKey(ui->streamPlot->xAxis->pixelToCoord(event->pos().x()));
sp->replot();
} else {
if (rubber_band_ && rubber_band_->isVisible() && event) {
rubber_band_->setGeometry(QRect(rb_origin_, event->pos()).normalized());
QRectF zoom_ranges = getZoomRanges(QRect(rb_origin_, event->pos()));
if (zoom_ranges.width() > 0.0 && zoom_ranges.height() > 0.0) {
hint += tr("Release to zoom, x = %1 to %2, y = %3 to %4")
.arg(zoom_ranges.x())
.arg(zoom_ranges.x() + zoom_ranges.width())
.arg(zoom_ranges.y())
.arg(zoom_ranges.y() + zoom_ranges.height());
} else {
hint += tr("Unable to select range.");
}
} else {
hint += tr("Click to select a portion of the graph.");
}
}
hint += " " + stream_desc_ + "</i></small>";
ui->hintLabel->setText(hint);
}