当前位置: 首页>>代码示例>>C++>>正文


C++ QPen函数代码示例

本文整理汇总了C++中QPen函数的典型用法代码示例。如果您正苦于以下问题:C++ QPen函数的具体用法?C++ QPen怎么用?C++ QPen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了QPen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WiresharkDialog

Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
    WiresharkDialog(parent, cf),
    ui(new Ui::Iax2AnalysisDialog),
    port_src_fwd_(0),
    port_dst_fwd_(0),
    port_src_rev_(0),
    port_dst_rev_(0),
    save_payload_error_(TAP_IAX2_NO_ERROR)
{
    ui->setupUi(this);
    loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5);
    setWindowSubtitle(tr("IAX2 Stream Analysis"));

    ui->progressFrame->hide();

    stream_ctx_menu_.addAction(ui->actionGoToPacket);
    stream_ctx_menu_.addAction(ui->actionNextProblem);
    stream_ctx_menu_.addSeparator();
    stream_ctx_menu_.addAction(ui->actionSaveAudio);
    stream_ctx_menu_.addAction(ui->actionSaveForwardAudio);
    stream_ctx_menu_.addAction(ui->actionSaveReverseAudio);
    stream_ctx_menu_.addSeparator();
    stream_ctx_menu_.addAction(ui->actionSaveCsv);
    stream_ctx_menu_.addAction(ui->actionSaveForwardCsv);
    stream_ctx_menu_.addAction(ui->actionSaveReverseCsv);
    stream_ctx_menu_.addSeparator();
    stream_ctx_menu_.addAction(ui->actionSaveGraph);
    ui->forwardTreeWidget->installEventFilter(this);
    ui->forwardTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->forwardTreeWidget, SIGNAL(customContextMenuRequested(QPoint)),
                SLOT(showStreamMenu(QPoint)));
    ui->reverseTreeWidget->installEventFilter(this);
    ui->reverseTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->reverseTreeWidget, SIGNAL(customContextMenuRequested(QPoint)),
                SLOT(showStreamMenu(QPoint)));
    connect(ui->streamGraph, SIGNAL(mousePress(QMouseEvent*)),
            this, SLOT(graphClicked(QMouseEvent*)));

    graph_ctx_menu_.addAction(ui->actionSaveGraph);

    QStringList header_labels;
    for (int i = 0; i < ui->forwardTreeWidget->columnCount(); i++) {
        header_labels << ui->forwardTreeWidget->headerItem()->text(i);
    }
    ui->reverseTreeWidget->setHeaderLabels(header_labels);

    memset(&src_fwd_, 0, sizeof(address));
    memset(&dst_fwd_, 0, sizeof(address));
    memset(&src_rev_, 0, sizeof(address));
    memset(&dst_rev_, 0, sizeof(address));

    QList<QCheckBox *> graph_cbs = QList<QCheckBox *>()
            << ui->fJitterCheckBox << ui->fDiffCheckBox
            << ui->rJitterCheckBox << ui->rDiffCheckBox;

    for (int i = 0; i < num_graphs_; i++) {
        QCPGraph *graph = ui->streamGraph->addGraph();
        graph->setPen(QPen(ColorUtils::graphColor(i)));
        graph->setName(graph_cbs[i]->text());
        graphs_ << graph;
        graph_cbs[i]->setChecked(true);
        graph_cbs[i]->setIcon(StockIcon::colorIcon(ColorUtils::graphColor(i), QPalette::Text));
    }
    ui->streamGraph->xAxis->setLabel("Arrival Time");
    ui->streamGraph->yAxis->setLabel("Value (ms)");

    // We keep our temp files open for the lifetime of the dialog. The GTK+
    // UI opens and closes at various points.
    QString tempname = QString("%1/wireshark_iax2_f").arg(QDir::tempPath());
    fwd_tempfile_ = new QTemporaryFile(tempname, this);
    fwd_tempfile_->open();
    tempname = QString("%1/wireshark_iax2_r").arg(QDir::tempPath());
    rev_tempfile_ = new QTemporaryFile(tempname, this);
    rev_tempfile_->open();

    if (fwd_tempfile_->error() != QFile::NoError || rev_tempfile_->error() != QFile::NoError) {
        err_str_ = tr("Unable to save RTP data.");
        ui->actionSaveAudio->setEnabled(false);
        ui->actionSaveForwardAudio->setEnabled(false);
        ui->actionSaveReverseAudio->setEnabled(false);
    }

    QMenu *save_menu = new QMenu();
    save_menu->addAction(ui->actionSaveAudio);
    save_menu->addAction(ui->actionSaveForwardAudio);
    save_menu->addAction(ui->actionSaveReverseAudio);
    save_menu->addSeparator();
    save_menu->addAction(ui->actionSaveCsv);
    save_menu->addAction(ui->actionSaveForwardCsv);
    save_menu->addAction(ui->actionSaveReverseCsv);
    save_menu->addSeparator();
    save_menu->addAction(ui->actionSaveGraph);
    ui->buttonBox->button(QDialogButtonBox::Save)->setMenu(save_menu);

    ui->buttonBox->button(QDialogButtonBox::Close)->setDefault(true);

    resetStatistics();
    updateStatistics(); // Initialize stats if an error occurs

#if 0
//.........这里部分代码省略.........
开发者ID:alagoutte,项目名称:wireshark,代码行数:101,代码来源:iax2_analysis_dialog.cpp

示例2: PrivateData

/*!
  Default Constructor
  \param style Symbol Style

  The symbol is constructed with gray interior,
  black outline with zero width, no size and style 'NoSymbol'.
*/
QwtSymbol::QwtSymbol( Style style )
{
    d_data = new PrivateData( style, QBrush( Qt::gray ),
                              QPen( Qt::black ), QSize( 0.0, 0.0 ) );
}
开发者ID:BryanF1947,项目名称:GoldenCheetah,代码行数:12,代码来源:qwt_symbol.cpp

示例3: fopen_s

BOOL BasicGraph::LoadCSVDataFile(QString filename, TimeSeriesData* pOutputData)
{
   int rc;
   char tempString[64];
   FILE* pFile;
   // errno_t err = fopen_s(&pFile, filename.toLatin1().data(), "rt");
   errno_t err = fopen_s(&pFile, "C:/trainingdata/8286/TimeSeries/Average_Z.csv", "rt");
   if (err == 13)
   {
      CJTRACE(TRACE_ERROR_LEVEL, "ERROR: Failed to open file: PERMISSION DENIED", filename.toLatin1().data());
      return FALSE;
   }
   else if (err != 0)
   {
      CJTRACE(TRACE_ERROR_LEVEL, "ERROR: Failed to open file. err=%d, file=%s", err, filename.toLatin1().data());
      return FALSE;
   }
   pOutputData->filename = filename;

   // Get data name
   fscanf_s(pFile, "%s", tempString, 64);
   pOutputData->name.fromLatin1(tempString);
   pOutputData->name.remove(0, 5);
   CJTRACE(TRACE_ERROR_LEVEL, "Loading data file: %s", filename.toLatin1().data());
   CJTRACE(TRACE_ERROR_LEVEL, "   Name:  %s", pOutputData->name.toLatin1().data());

   // Get time delta in X axis
   fscanf_s(pFile, "%s", tempString, 64);
   pOutputData->timedelta = atof(&tempString[6]);
   CJTRACE(TRACE_ERROR_LEVEL, "   Delta: %.10lf (sec)", pOutputData->timedelta);

   // Get first X axis value
   fscanf_s(pFile, "%s", tempString, 64);
   pOutputData->timestart = atof(&tempString[5]);
   CJTRACE(TRACE_ERROR_LEVEL, "   Start: %.10lf (sec)", pOutputData->timestart);

   // Get X axis label
   fscanf_s(pFile, "%s", tempString, 64);
   pOutputData->Xaxislabel.fromLatin1(tempString);
   pOutputData->Xaxislabel.remove(0, 7);
   CJTRACE(TRACE_ERROR_LEVEL, "   X Axis: %s", pOutputData->Xaxislabel.toLatin1().data());

   // Get Y axis label
   fscanf_s(pFile, "%s", tempString, 64);
   pOutputData->Yaxislabel.fromLatin1(tempString);
   pOutputData->Yaxislabel.remove(0, 7);
   CJTRACE(TRACE_ERROR_LEVEL, "   Y Axis: %s", pOutputData->Yaxislabel.toLatin1().data());

   while (strcmp(tempString, "Values") != 0)
   {
      fscanf_s(pFile, "%s", tempString, 64);  // Data Notes (skip for now)
   }
   
   // Get data values
   rc = 0;
   int count = 0;
   QVector<double> time(0); 
   double nextTime = pOutputData->timestart;

   while (rc != EOF)
   {
      rc = fscanf_s(pFile, "%s", tempString, 64);
      pOutputData->pData.append(atof(tempString));
      time.append(nextTime);
      nextTime += pOutputData->timedelta;
      count++;
      if ((count < 50) || (count % 500 == 0))
      CJTRACE(TRACE_ERROR_LEVEL, "   Value: %d, %.10lf", count, pOutputData->timedelta);
   }
   CJTRACE(TRACE_ERROR_LEVEL, "Data File Read (%d entries)", count);

   QCustomPlot* customPlot = ui.basicGraph;

   // add two new graphs and set their look:
   customPlot->addGraph();
   customPlot->graph(0)->setPen(QPen(Qt::blue)); // line color blue for first graph
   // configure right and top axis to show ticks but no labels:
   // (see QCPAxisRect::setupFullAxesBox for a quicker method to do this)
   customPlot->xAxis2->setVisible(true);
   customPlot->xAxis2->setTickLabels(false);
   customPlot->yAxis2->setVisible(true);
   customPlot->yAxis2->setTickLabels(false);
   // make left and bottom axes always transfer their ranges to right and top axes:
   connect(customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->xAxis2, SLOT(setRange(QCPRange)));
   connect(customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->yAxis2, SLOT(setRange(QCPRange)));
   // pass data points to graphs:
   customPlot->graph(0)->setData(time, pOutputData->pData);

   // let the ranges scale themselves so graph 0 fits perfectly in the visible area:
   customPlot->graph(0)->rescaleAxes();
   // same thing for graph 1, but only enlarge ranges (in case graph 1 is smaller than graph 0):
   //customPlot->graph(1)->rescaleAxes(true);
   // Note: we could have also just called customPlot->rescaleAxes(); instead
   // Allow user to drag axis ranges with mouse, zoom with mouse wheel and select graphs by clicking:
   customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);

   ExternalReplot();

   return TRUE;
}
开发者ID:jkane1628,项目名称:HtmControlCenter,代码行数:100,代码来源:basicgraph.cpp

示例4: QPen

 **	this files contains a subclass of Touch
 **
 **	Contributors:
 **		Benjamin Tissoires <[email protected]>
 **
 **
 **	This program is provided to you as free software;
 **	you can redistribute it	and/or modify it under the terms of the
 **	GNU General Public License as published by the Free Software
 **	Foundation; either version 2 of the License, or (at your option)
 **	any later version.
 **/

#include "drawingtouch.h"

static QPen pressedPen = QPen(Qt::black, 5);
static QPen releasedPen = QPen(Qt::black, 1);

DrawingTouch::DrawingTouch(QGraphicsScene *scene, int radius, QObject *parent) :
    Touch(parent),
    scene(scene),
    ellipse(0),
    radius(radius)
{
}

bool DrawingTouch::update(QBrush *color)
{
    bool wasVisible = false;
    if (ellipse) {
        wasVisible = ellipse->isVisible();
开发者ID:bentiss,项目名称:mtdiag-qt,代码行数:31,代码来源:drawingtouch.cpp

示例5: sizeHint

void QBalloonTip::balloon(const QPoint& pos, int msecs, bool showArrow)
{
    QRect scr = QApplication::desktop()->screenGeometry(pos);
    QSize sh = sizeHint();
    const int border = 1;
    const int ah = 18, ao = 18, aw = 18, rc = 7;
    bool arrowAtTop = (pos.y() + sh.height() + ah < scr.height());
    bool arrowAtLeft = (pos.x() + sh.width() - ao < scr.width());
    setContentsMargins(border + 3,  border + (arrowAtTop ? ah : 0) + 2, border + 3, border + (arrowAtTop ? 0 : ah) + 2);
    updateGeometry();
    sh  = sizeHint();

    int ml, mr, mt, mb;
    QSize sz = sizeHint();
    if (!arrowAtTop) {
        ml = mt = 0;
        mr = sz.width() - 1;
        mb = sz.height() - ah - 1;
    } else {
        ml = 0;
        mt = ah;
        mr = sz.width() - 1;
        mb = sz.height() - 1;
    }

    QPainterPath path;
#if defined(QT_NO_XSHAPE) && defined(Q_WS_X11)
    // XShape is required for setting the mask, so we just
    // draw an ugly square when its not available
    path.moveTo(0, 0);
    path.lineTo(sz.width() - 1, 0);
    path.lineTo(sz.width() - 1, sz.height() - 1);
    path.lineTo(0, sz.height() - 1);
    path.lineTo(0, 0);
    move(qMax(pos.x() - sz.width(), scr.left()), pos.y());
#else
    path.moveTo(ml + rc, mt);
    if (arrowAtTop && arrowAtLeft) {
        if (showArrow) {
            path.lineTo(ml + ao, mt);
            path.lineTo(ml + ao, mt - ah);
            path.lineTo(ml + ao + aw, mt);
        }
        move(qMax(pos.x() - ao, scr.left() + 2), pos.y());
    } else if (arrowAtTop && !arrowAtLeft) {
        if (showArrow) {
            path.lineTo(mr - ao - aw, mt);
            path.lineTo(mr - ao, mt - ah);
            path.lineTo(mr - ao, mt);
        }
        move(qMin(pos.x() - sh.width() + ao, scr.right() - sh.width() - 2), pos.y());
    }
    path.lineTo(mr - rc, mt);
    path.arcTo(QRect(mr - rc*2, mt, rc*2, rc*2), 90, -90);
    path.lineTo(mr, mb - rc);
    path.arcTo(QRect(mr - rc*2, mb - rc*2, rc*2, rc*2), 0, -90);
    if (!arrowAtTop && !arrowAtLeft) {
        if (showArrow) {
            path.lineTo(mr - ao, mb);
            path.lineTo(mr - ao, mb + ah);
            path.lineTo(mr - ao - aw, mb);
        }
        move(qMin(pos.x() - sh.width() + ao, scr.right() - sh.width() - 2),
             pos.y() - sh.height());
    } else if (!arrowAtTop && arrowAtLeft) {
        if (showArrow) {
            path.lineTo(ao + aw, mb);
            path.lineTo(ao, mb + ah);
            path.lineTo(ao, mb);
        }
        move(qMax(pos.x() - ao, scr.x() + 2), pos.y() - sh.height());
    }
    path.lineTo(ml + rc, mb);
    path.arcTo(QRect(ml, mb - rc*2, rc*2, rc*2), -90, -90);
    path.lineTo(ml, mt + rc);
    path.arcTo(QRect(ml, mt, rc*2, rc*2), 180, -90);

    // Set the mask
    QBitmap bitmap = QBitmap(sizeHint());
    bitmap.fill(Qt::color0);
    QPainter painter1(&bitmap);
    painter1.setPen(QPen(Qt::color1, border));
    painter1.setBrush(QBrush(Qt::color1));
    painter1.drawPath(path);
    setMask(bitmap);
#endif

    // Draw the border
    pixmap = QPixmap(sz);
    QPainter painter2(&pixmap);
    painter2.setPen(QPen(palette().color(QPalette::Window).darker(160), border));
    painter2.setBrush(palette().color(QPalette::Window));
    painter2.drawPath(path);

    if (msecs > 0)
        timerId = startTimer(msecs);
    show();
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:98,代码来源:qsystemtrayicon.cpp

示例6: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::MainWindow),
  m_accelXPoints(100, QPointF(0, 0)), m_accelYPoints(100, QPointF(0, 0)),
  m_gyroXPoints(100, QPointF(0, 0)), m_gyroYPoints(100, QPointF(0, 0)),
  m_counter(0), m_power(0)
{
	ui->setupUi(this);

	// init scenes
	xScene = new QGraphicsScene();
	yScene = new QGraphicsScene();
	xScene->setBackgroundBrush(Qt::white);
	yScene->setBackgroundBrush(Qt::white);
	ui->xGraphicsView->setScene(xScene);
	ui->yGraphicsView->setScene(yScene);

	m_tcpSocket = new QTcpSocket(this);
	connect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(onTcpRead()));

	m_controlSocket = new QTcpSocket(this);
	connect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(onControlRead()));

	// connecting
	connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(connectToServer()));
	connect(ui->disconnectButton, SIGNAL(clicked()), this, SLOT(disconnectFromServer()));

	// control buttons
	connect(ui->up2Button, SIGNAL(clicked()), this, SLOT(handleControlButton()));
	connect(ui->up1Button, SIGNAL(clicked()), this, SLOT(handleControlButton()));
	connect(ui->zeroButton, SIGNAL(clicked()), this, SLOT(handleControlButton()));
	connect(ui->down1Button, SIGNAL(clicked()), this, SLOT(handleControlButton()));
	connect(ui->down2Button, SIGNAL(clicked()), this, SLOT(handleControlButton()));

	// plotting setup
	m_accelXData = new QwtPointSeriesData();
	m_accelYData = new QwtPointSeriesData();
	m_accelXCurve = new QwtPlotCurve("Accel X");
	m_accelYCurve = new QwtPlotCurve("Accel Y");
	m_accelXCurve->setPen( QPen( Qt::black ) );
	m_accelYCurve->setPen( QPen( Qt::red));
	m_accelXCurve->attach( ui->plot );
	m_accelYCurve->attach(ui->plot);

	m_gyroXData = new QwtPointSeriesData();
	m_gyroYData = new QwtPointSeriesData();
	m_gyroXCurve = new QwtPlotCurve("Gyro X");
	m_gyroYCurve = new QwtPlotCurve("Gyro Y");
	m_gyroXCurve->setPen( QPen( Qt::green ) );
	m_gyroYCurve->setPen( QPen( Qt::blue));
	m_gyroXCurve->attach( ui->plot );
	m_gyroYCurve->attach(ui->plot);

	ui->plot->setCanvasBackground(Qt::white);
	// Axes
	ui->plot->setAxisTitle( QwtPlot::xBottom, "Seconds" );
	ui->plot->setAxisTitle( QwtPlot::yLeft, "Degrees" );
	ui->plot->setAxisScale( QwtPlot::yLeft, -90, 90 );

	// zero line
	QwtPlotMarker* zeroMarker = new QwtPlotMarker();
	zeroMarker->setLineStyle(QwtPlotMarker::HLine);
	zeroMarker->setLinePen(QPen(Qt::DotLine));
	zeroMarker->setSymbol(new QwtSymbol(QwtSymbol::HLine));
	zeroMarker->setYValue(0);
	zeroMarker->attach(ui->plot);

	updatePlot(0, 0, 0, 0);
}
开发者ID:Dnike,项目名称:copter-telemetrics,代码行数:69,代码来源:mainwindow.cpp

示例7: createOutputGraph

void FFT::outputGraphs()
{
	createOutputGraph();

	MultiLayer *ml = d_output_graph->multiLayer();

	d_output_graph->setTitle(QString::null);
	d_output_graph->setYAxisTitle(tr("Angle (deg)"));
	d_output_graph->enableAxis(QwtPlot::xTop, true);
	d_output_graph->enableAxis(QwtPlot::yRight, true);
	if (!d_inverse)
		d_output_graph->setAxisTitle(QwtPlot::xTop, tr("Frequency") + " (" + tr("Hz") + ")");
	else
		d_output_graph->setAxisTitle(QwtPlot::xTop, tr("Time") + + " (" + tr("s") + ")");

	ScaleDraw *sd = (ScaleDraw *)d_output_graph->axisScaleDraw(QwtPlot::yLeft);
	if (sd)
		sd->setShowTicksPolicy(ScaleDraw::HideBegin);
	sd = (ScaleDraw *)d_output_graph->axisScaleDraw(QwtPlot::yRight);
	if (sd)
		sd->setShowTicksPolicy(ScaleDraw::HideBegin);
	sd = (ScaleDraw *)d_output_graph->axisScaleDraw(QwtPlot::xBottom);
	if (sd){
		sd->setShowTicksPolicy(ScaleDraw::HideBeginEnd);
		sd->enableComponent(QwtAbstractScaleDraw::Backbone, false);
	}

	QString tableName = d_result_table->objectName();
	PlotCurve *pc = d_output_graph->insertCurve(d_result_table, 0, tableName + "_" + tr("Angle"), 0);
	pc->setPen(QPen(d_curveColor, 1));
	d_output_graph->removeLegend();
	d_output_graph->updatePlot();

	Graph *g = ml->addLayer(0, 0, 0, 0, true);
	g->setTitle(QString::null);
	if (!d_inverse)
		g->setXAxisTitle(tr("Frequency") + " (" + tr("Hz") + ")");
	else
		g->setXAxisTitle(tr("Time") + + " (" + tr("s") + ")");
	g->setYAxisTitle(tr("Amplitude"));
	g->removeLegend();

	sd = (ScaleDraw *)g->axisScaleDraw(QwtPlot::xTop);
	if (sd)
		sd->setShowTicksPolicy(ScaleDraw::HideBeginEnd);

	PlotCurve *c = g->insertCurve(d_result_table, 0, tableName + "_" + tr("Amplitude"), 0);
	c->setPen(QPen(d_curveColor, 1));
	g->updatePlot();

	double rb = g->axisScaleDiv(QwtPlot::xBottom)->upperBound();
	d_output_graph->setAxisScale(QwtPlot::xBottom, 0, rb);
	d_output_graph->setAxisScale(QwtPlot::xTop, 0, rb);
	g->setAxisScale(QwtPlot::xBottom, 0, rb);
	g->setAxisScale(QwtPlot::xTop, 0, rb);

	ml->setAlignPolicy(MultiLayer::AlignCanvases);
	ml->setRows(2);
	ml->setCols(1);
	ml->setSpacing(0, 0);
	ml->linkXLayerAxes();
	ml->setCommonLayerAxes(false, true);
	ml->arrangeLayers(false, false);
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:64,代码来源:FFT.cpp

示例8: style

void KTExposureHeader::paintSection(QPainter * painter, const QRect & rect, int layerIndex) const
{
    if (!rect.isValid()) 
        return;

    QStyleOptionHeader headerOption;
    headerOption.rect = rect;
    headerOption.orientation = Qt::Horizontal;
    headerOption.position = QStyleOptionHeader::Middle;
    headerOption.text = "";

    QStyle::State state = QStyle::State_None;

    if (isEnabled())
        state |= QStyle::State_Enabled;

    if (window()->isActiveWindow())
        state |= QStyle::State_Active;

    style()->drawControl(QStyle::CE_HeaderSection, &headerOption, painter);

    QString text = m_layers[layerIndex].title;
    QFont font("Arial", 8, QFont::Normal, false);
    QFontMetrics fm(font);

    QStyleOptionButton buttonOption;

    if (m_layers[layerIndex].isVisible) {
        buttonOption.palette.setBrush(QPalette::Button, Qt::green);
    } else {
        buttonOption.palette.setBrush(QPalette::Button, Qt::red);
        buttonOption.state |= QStyle::State_Sunken;
        QColor color(255, 0, 0, 40);
        painter->fillRect(rect.normalized().adjusted(0, 1, 0, -1), color);
    }

    if ((layerIndex == currentCol) || (m_layers.size() == 1)) {
        QColor color(250, 209, 132, 80);
        painter->fillRect(rect.normalized().adjusted(0, 1, 0, -1), color);
        if (m_layers[layerIndex].isVisible) {
            painter->setPen(QPen(QColor(250, 209, 132, 255), 2, Qt::SolidLine)); // Header selected
            painter->drawRect(rect.normalized().adjusted(0, 1, 0, -1));
        } else { 
            painter->setPen(QPen(QColor(255, 0, 0, 70), 2, Qt::SolidLine)); // Header locked
            painter->drawRect(rect.normalized().adjusted(0, 1, 0, -1));
        }
    }

    int buttonWidth = 12;
    int width = (rect.normalized().width() - (fm.width(text) + buttonWidth) + 4)/ 2;
    int x = rect.normalized().x() + width + buttonWidth;
    int y = rect.normalized().bottomLeft().y() - (1 + (rect.normalized().height() - fm.height())/2);

    painter->setFont(font);
    painter->setPen(QPen(Qt::black, 1, Qt::SolidLine));
    painter->drawText(x, y, text);

    buttonOption.rect = QRect(rect.x() + width - 4, rect.y() + ((rect.normalized().height()-buttonWidth)/2) + 1, buttonWidth, buttonWidth);
  
    style()->drawControl(QStyle::CE_PushButton, &buttonOption, painter);
}
开发者ID:BackupTheBerlios,项目名称:ktoon-svn,代码行数:61,代码来源:ktexposureheader.cpp

示例9: width

void RulerT::paintEvent(QPaintEvent *)
{
	double xl;
	QPainter p;
	p.begin(this);
	p.drawLine(0, 24, width(), 24);
	p.translate(-offset, 0);
	p.setBrush(Qt::black);
	p.setFont(font());
	p.setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
	for (xl = 0; xl < width()+offset; xl += iter)
	{
		if (xl < offset)
			continue;
		p.drawLine(qRound(xl), 18, qRound(xl), 24);
	}
	for (xl = 0; xl < width()+(iter2/2)+offset; xl += iter2)
	{
		if (xl < offset)
			continue;
		p.drawLine(qRound(xl), 11, qRound(xl), 24);
		switch (unitIndex)
		{
			case 2:
			{
				QString tx = "";
				int num1 = static_cast<int>(xl / iter2);
				if (num1 != 0)
					tx = QString::number(num1);
				double frac = (xl / iter2) - num1;
				if ((frac > 0.24) && (frac < 0.26))
					tx += QChar(0xBC);
				if ((frac > 0.49) && (frac < 0.51))
					tx += QChar(0xBD);
				if ((frac > 0.74) && (frac < 0.76))
					tx += QChar(0xBE);
				p.drawText(qRound(xl+2), 17, tx);
				break;
			}
			case 3:
				p.drawText(qRound(xl+2), 17, QString::number(xl / iter));
				break;
			default:
				p.drawText(qRound(xl+2), 17, QString::number(xl / iter * 10));
				break;
		}
	}
	if (tabValues.count() != 0)
	{
		for (int yg = 0; yg < static_cast<int>(tabValues.count()); yg++)
		{
			if (yg == actTab)
				p.setPen(QPen(Qt::red, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
			else
				p.setPen(QPen(Qt::black, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
			switch (static_cast<int>(tabValues[yg].tabType))
			{
				case 0:
					p.drawLine(qRound(tabValues[yg].tabPosition), 15, qRound(tabValues[yg].tabPosition), 23);
					p.drawLine(qRound(tabValues[yg].tabPosition), 23, qRound(tabValues[yg].tabPosition+8), 23);
					break;
				case 1:
					p.drawLine(qRound(tabValues[yg].tabPosition), 15, qRound(tabValues[yg].tabPosition), 23);
					p.drawLine(qRound(tabValues[yg].tabPosition), 23, qRound(tabValues[yg].tabPosition-8), 23);
					break;
				case 2:
				case 3:
					p.drawLine(qRound(tabValues[yg].tabPosition), 15, qRound(tabValues[yg].tabPosition), 23);
					p.drawLine(qRound(tabValues[yg].tabPosition-4), 23, qRound(tabValues[yg].tabPosition+4), 23);
					p.drawLine(qRound(tabValues[yg].tabPosition+3), 20, qRound(tabValues[yg].tabPosition+2), 20);
					break;
				case 4:
					p.drawLine(qRound(tabValues[yg].tabPosition), 15, qRound(tabValues[yg].tabPosition), 23);
					p.drawLine(qRound(tabValues[yg].tabPosition-4), 23, qRound(tabValues[yg].tabPosition+4), 23);
					break;
				default:
					break;
			}
		}
	}
	if (haveInd)
	{
		p.setPen(QPen(Qt::blue, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
		p.setBrush(Qt::blue);
		QPolygon cr;
		cr.setPoints(3, qRound(firstLine+leftIndent), 12, qRound(firstLine+leftIndent-4), 0, qRound(firstLine+leftIndent+4), 0);
		p.drawPolygon(cr);
		QPolygon cr2;
		cr2.setPoints(3, qRound(leftIndent), 12, qRound(leftIndent+4), 24, qRound(leftIndent-4), 24);
		p.drawPolygon(cr2);
	}
	p.end();
}
开发者ID:pvanek,项目名称:scribus-cuba-trunk,代码行数:93,代码来源:tabruler.cpp

示例10: QPainter

void EasingGraph::paintEvent(QPaintEvent *event)
//void EasingGraph::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
    QWidget::paintEvent(event);

    QPainter *painter = new QPainter(this);
    painter->save();
    bool drawZero = false;

    // no background

    int length = width();
    int breadth = height()-2;
    QPainterPath path;
    path.moveTo(0,int((1-m_curveFunction.valueForProgress(0))*breadth));
    for (int i=0;i<length;i++) {
        qreal progress = i/qreal(length);
        qreal value = m_curveFunction.valueForProgress(progress);
        int x = int(length*progress);
        int y = int(breadth*(1-value));
        path.lineTo(x,y);
    }

    QRectF pathRect = path.controlPointRect();
    if ( (pathRect.height()>breadth)) {
        // scale vertically
        qreal scale = breadth/pathRect.height();
        qreal displacement = -pathRect.top();

        // reset path and recompute scaled version
        path = QPainterPath();
        path.moveTo(0,int(scale*((1-m_curveFunction.valueForProgress(0))*breadth+displacement)));
        for (int i=0;i<length;i++) {
            qreal progress = i/qreal(length);
            qreal value = m_curveFunction.valueForProgress(progress);
            int x = int(length*progress);
            int y = int(scale*(breadth*(1-value)+displacement));
            path.lineTo(x,y);
        }

        drawZero = true;
    }


    painter->setBrush(Qt::transparent);

    if (drawZero) {
        // "zero" and "one" lines
        QPen zeroPen = QPen(m_zeroColor);
        zeroPen.setStyle(Qt::DashLine);
        painter->setPen(zeroPen);
        int y = int(-pathRect.top()*breadth/pathRect.height());
        if (y>0)
            painter->drawLine(0,y,length,y);
        y = int(breadth/pathRect.height()*(breadth-pathRect.top()));
        if (y<breadth)
            painter->drawLine(0,y,length,y);
    }

    painter->setPen(m_color);
    painter->drawPath(path);
    painter->restore();
    delete painter;
}
开发者ID:FlavioFalcao,项目名称:qt-creator,代码行数:64,代码来源:easinggraph.cpp

示例11: QwtPolarPlot

Plot::Plot(QWidget *parent)
    : QwtPolarPlot(parent)
    , m_azimuthChange(new QTimer(this))
    , m_currTime(new QTime)
    , m_nextAzimuthData(new QTimer(this))
    , m_isStarted(false)
    , m_showIDs(true)
    , m_tracksStorage(new MarksTracksStorage(this))
      /*, m_picker(new QwtPolarPicker(QwtPicker::CrossRubberBand,
                                    QwtPicker::ActiveOnly,
                                    this->canvas()))*/
    , m_isIDMoving(false)
    , m_currMovingCurveID(0)
    , m_wrongMarksSound(new QSound(":/Resources/WrongMarksReceived.wav", this))
    , m_rightMarksSound(new QSound(":/Resources/RadarShort.wav", this))
    , m_offSounds(false)
    , m_markIndex(0)
    , m_upToIndex(0)
    , m_isIndexMarkFirstAppearance(true)
    , m_pauseAzimuth(0.0)
    , m_isPaused(false)
{
    m_tracksStorage->setStorageSize(40);

    /*m_picker->setStateMachine(new QwtPickerDragPointMachine);
    m_picker->setMousePattern(QwtPicker::MouseSelect1, Qt::LeftButton);
    m_picker->setRubberBandPen(QColor("#00FF00"));
    m_picker->setTrackerPen(QColor(Qt::white));
    m_picker->setTrackerFont(QFont("Verdana", 10));*/

    setAutoReplot( false );
    setPlotBackground( QColor("#0B0B3B") );
    canvas()->setStyleSheet("background: #0B0B3B");
    // Maked plot squared
    this->zoom(QwtPointPolar(0, 0), ZOOMDEFAULTFACTOR);

    // setting start point at 12 o'clock
    setAzimuthOrigin(M_PI/2);

    // scales
    setScale(QwtPolar::Azimuth, 360, 0, 30);
    setScaleMaxMinor(QwtPolar::Azimuth, 30);
    setScaleMaxMajor(QwtPolar::Azimuth, 30);

    setScale(QwtPolar::Radius, 0.0, 400.0 / ZOOMDEFAULTFACTOR, 50.0);
    setScaleMaxMinor(QwtPolar::Radius, qCeil(400.0 / (50.0 * ZOOMDEFAULTFACTOR)));
    setScaleMaxMajor(QwtPolar::Radius, qCeil(400.0 / (50.0 * ZOOMDEFAULTFACTOR)));

    // grids
    m_grid = new QwtPolarGrid();
    m_grid->setPen(QPen(Qt::gray));
    for(int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++)
    {
        m_grid->showGrid(scaleId);
    }
    m_grid->setAxisPen(QwtPolar::AxisAzimuth, QPen(Qt::gray));
    m_grid->setAzimuthScaleDraw(new AzimuthScaleDraw());
    m_grid->showAxis(QwtPolar::AxisAzimuth, true);
    m_grid->showAxis(QwtPolar::AxisLeft, false);
    m_grid->showAxis(QwtPolar::AxisRight, true);
    m_grid->showAxis(QwtPolar::AxisTop, false);
    m_grid->showAxis(QwtPolar::AxisBottom, false);
    m_grid->showGrid(QwtPolar::Azimuth, true);
    m_grid->showGrid(QwtPolar::Radius, true);
    m_grid->attach(this);

    setMinimumSize(defaultPlotSize);

    m_currAzimuth = 0;
    QVector<double> azimuth;
    QVector<double> radius;
    azimuth.fill(m_currAzimuth, 2);
    radius.append(0);
    radius.append(maxBeamRadius);
    m_beamCurve = new QwtPolarCurve;
    m_beamCurve->setPen(QPen(QBrush(Qt::green), beamPenWidth));
    m_beamData = new Data(azimuth, radius, beamId);

    m_beamCurve->setData(m_beamData);
    m_beamCurve->attach(this);

    // Blind Zone Curve
    radius.clear();
    azimuth.clear();
    radius.fill(5, 33);
    for(double i = 0; i <= 360; i += 11.25) {
        azimuth.append(i);
    }
    QwtPolarCurve *blindZoneCurve = new QwtPolarCurveJamming;
    blindZoneCurve->setPen(QPen(QBrush(Qt::yellow), 0));
    Data *blindZoneData = new Data(azimuth, radius, 0x10000);
    blindZoneCurve->setData(blindZoneData);
    blindZoneCurve->attach(this);

    m_cycleTime = Cicle10;
    m_azimuthChange->setInterval(cicleInterval);

    m_nextAzimuthData->setInterval(packetsInterval);

    connect(m_azimuthChange, SIGNAL(timeout()), this, SLOT(azimuthChanged()));
//.........这里部分代码省略.........
开发者ID:BulSV,项目名称:Radar,代码行数:101,代码来源:Plot.cpp

示例12: maximum

void ProgressBar::paintEvent(QPaintEvent *)
{
    // TODO move font into Utils::StyleHelper
    // TODO use Utils::StyleHelper white

    double range = maximum() - minimum();
    double percent = 0.50;
    if (range != 0)
        percent = (value() - minimum()) / range;
    if (percent > 1)
        percent = 1;
    else if (percent < 0)
        percent = 0;

    QPainter p(this);
    QFont boldFont(p.font());
    boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
    boldFont.setBold(true);
    p.setFont(boldFont);
    QFontMetrics fm(boldFont);

    // Draw separator
    int h = fm.height();
    p.setPen(QColor(0, 0, 0, 70));
    p.drawLine(0,0, size().width(), 0);

    p.setPen(QColor(255, 255, 255, 70));
    p.drawLine(0, 1, size().width(), 1);

    QRect textRect = rect().adjusted(0, 0, -1, 0);
    textRect.setHeight(h+5);

    p.setPen(QColor(30, 30, 30, 80));
    p.drawText(textRect, Qt::AlignHCenter | Qt::AlignBottom, m_title);
    p.translate(0, -1);
    p.setPen(Utils::StyleHelper::panelTextColor());
    p.drawText(textRect, Qt::AlignHCenter | Qt::AlignBottom, m_title);
    p.translate(0, 1);

    m_progressHeight = PROGRESSBAR_HEIGHT;
    m_progressHeight += ((m_progressHeight % 2) + 1) % 2; // make odd
    // draw outer rect
    QRect rect(INDENT - 1, h+6, size().width()-2*INDENT, m_progressHeight-1);
    p.setPen(Utils::StyleHelper::panelTextColor());
    p.drawRect(rect);

    // draw inner rect
    QColor c = Utils::StyleHelper::panelTextColor();
    c.setAlpha(180);
    p.setPen(Qt::NoPen);

    QRect inner = rect.adjusted(2, 2, -1, -1);
    inner.adjust(0, 0, qRound((percent - 1) * inner.width()), 0);
    if (m_error) {
        QColor red(255, 60, 0, 210);
        c = red;
        // avoid too small red bar
        if (inner.width() < 10)
            inner.adjust(0, 0, 10 - inner.width(), 0);
    } else if (value() == maximum()) {
        c = QColor(120, 245, 90, 180);
    }

    QLinearGradient grad(inner.topLeft(), inner.bottomLeft());
    grad.setColorAt(0, c.lighter(114));
    grad.setColorAt(0.5, c.lighter(104));
    grad.setColorAt(0.51, c.darker(108));
    grad.setColorAt(1, c.darker(120));

    p.setBrush(grad);
    p.drawRect(inner);

    if (value() < maximum() && !m_error) {
        QColor cancelOutline = Utils::StyleHelper::panelTextColor();
        p.setPen(cancelOutline);
        QRect cancelRect(rect.right() - m_progressHeight + 2, rect.top(), m_progressHeight-1, rect.height());
        if (cancelRect.contains(mapFromGlobal(QCursor::pos())))
            p.setBrush(QColor(230, 90, 40, 190));
        else
            p.setBrush(Qt::NoBrush);

        p.drawRect(cancelRect);

        p.setPen(QPen(QColor(0, 0, 0, 70), 3));
        p.drawLine(cancelRect.center()+QPoint(-1,-1), cancelRect.center()+QPoint(+3,+3));
        p.drawLine(cancelRect.center()+QPoint(+3,-1), cancelRect.center()+QPoint(-1,+3));

        p.setPen(Utils::StyleHelper::panelTextColor());
        p.drawLine(cancelRect.center()+QPoint(-1,-1), cancelRect.center()+QPoint(+3,+3));
        p.drawLine(cancelRect.center()+QPoint(+3,-1), cancelRect.center()+QPoint(-1,+3));
    }
}
开发者ID:HiroyukiSeki,项目名称:qtplatz,代码行数:92,代码来源:progresspie.cpp

示例13: switch

/*!\reimp
 */
void QPlatinumStyle::drawPrimitive( PrimitiveElement pe,
				    QPainter *p,
				    const QRect &r,
				    const QColorGroup &cg,
				    SFlags flags,
				    const QStyleOption& opt ) const
{
    switch (pe) {
    case PE_HeaderSection:
	{
	    // adjust the sunken flag, otherwise headers are drawn
	    // sunken...
	    if ( flags & Style_Sunken )
		flags ^= Style_Sunken;
	    drawPrimitive( PE_ButtonBevel, p, r, cg, flags, opt );
	    break;
	}
    case PE_ButtonTool:
	{
	    // tool buttons don't change color when pushed in platinum,
	    // so we need to make the mid and button color the same
	    QColorGroup myCG = cg;
	    QBrush fill;

	    // quick trick to make sure toolbuttons drawn sunken
	    // when they are activated...
	    if ( flags & Style_On )
		flags |= Style_Sunken;

	    fill = myCG.brush( QColorGroup::Button );
	    myCG.setBrush( QColorGroup::Mid, fill );
	    drawPrimitive( PE_ButtonBevel, p, r, myCG, flags, opt );
	    break;
	}
    case PE_ButtonBevel:
	{
	    int x,
		y,
		w,
		h;
	    r.rect( &x, &y, &w, &h );

	    QPen oldPen = p->pen();
	    if ( w * h < 1600 ||
		 QABS(w - h) > 10 ) {
		// small buttons

		if ( !(flags & (Style_Sunken | Style_Down)) ) {
		    p->fillRect( x + 2, y + 2, w - 4, h - 4,
				 cg.brush(QColorGroup::Button) );
		    // the bright side
		    p->setPen( cg.dark() );
		    // the bright side
		    p->setPen( cg.dark() );
		    p->drawLine( x, y, x + w - 1, y );
		    p->drawLine( x, y, x, y + h - 1 );

		    p->setPen( cg.light() );
		    p->drawLine( x + 1, y + 1, x + w - 2, y + 1 );
		    p->drawLine( x + 1, y + 1, x + 1, y + h - 2 );

		    // the dark side
		    p->setPen( cg.mid() );
		    p->drawLine( x + 2, y + h - 2, x + w - 2, y + h - 2 );
		    p->drawLine( x + w - 2, y + 2, x + w - 2, y + h - 3 );

		    p->setPen( cg.dark().dark() );
		    p->drawLine( x + 1, y + h - 1, x + w - 1,
				 y + h - 1 );
		    p->drawLine( x + w - 1, y + 1,
				 x + w - 1,
				 y + h - 2 );
		} else {
		    p->fillRect(x + 2, y + 2,
				w - 4, h - 4,
				cg.brush( QColorGroup::Mid ));

		    // the dark side
		    p->setPen( cg.dark().dark() );
		    p->drawLine( x, y, x + w - 1, y );
		    p->drawLine( x, y, x, y + h - 1 );

		    p->setPen( cg.mid().dark());
		    p->drawLine( x + 1, y + 1,
				 x + w-2, y + 1);
		    p->drawLine( x + 1, y + 1,
				 x + 1, y + h - 2 );


		    // the bright side!

		    p->setPen(cg.button());
		    p->drawLine( x + 1, y + h - 2,
				 x + w - 2,
				 y + h - 2 );
		    p->drawLine( x + w - 2, y + 1,
				 x + w - 2,
				 y + h - 2 );
//.........这里部分代码省略.........
开发者ID:AliYousuf,项目名称:univ-aca-mips,代码行数:101,代码来源:qplatinumstyle.cpp

示例14: cosmetic

/*!
  Build and assign the symbol pen

  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
  non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
  to hide this incompatibility.

  \param color Pen color
  \param width Pen width
  \param style Pen style

  \sa pen(), brush()
 */
void QwtPlotTradingCurve::setSymbolPen(
    const QColor &color, qreal width, Qt::PenStyle style )
{
    setSymbolPen( QPen( color, width, style ) );
}
开发者ID:svn2github,项目名称:Qwt_trunk,代码行数:18,代码来源:qwt_plot_tradingcurve.cpp

示例15: QColor

QString UBSettings::uniboardDocumentNamespaceUri = "http://uniboard.mnemis.com/document";
QString UBSettings::uniboardApplicationNamespaceUri = "http://uniboard.mnemis.com/application";


const int UBSettings::sDefaultFontPixelSize = 36;
const char *UBSettings::sDefaultFontFamily = "Arial";

QString UBSettings::currentFileVersion = "4.6.0";

QColor UBSettings::crossDarkBackground = QColor(44, 44, 44, 200);
QColor UBSettings::crossLightBackground = QColor(165, 225, 255);

QBrush UBSettings::eraserBrushLightBackground = QBrush(QColor(255, 255, 255, 30));
QBrush UBSettings::eraserBrushDarkBackground = QBrush(QColor(127, 127, 127, 30));

QPen UBSettings::eraserPenDarkBackground = QPen(QColor(255, 255, 255, 63));
QPen UBSettings::eraserPenLightBackground = QPen(QColor(0, 0, 0, 63));

QColor UBSettings::documentSizeMarkColorDarkBackground = QColor(44, 44, 44, 200);
QColor UBSettings::documentSizeMarkColorLightBackground = QColor(241, 241, 241);

QColor UBSettings::paletteColor = QColor(127, 127, 127, 127);
QColor UBSettings::opaquePaletteColor = QColor(66, 66, 66, 200);

QColor UBSettings::documentViewLightColor = QColor(241, 241, 241);

QPointer<QSettings> UBSettings::sAppSettings = 0;

const int UBSettings::maxThumbnailWidth = 400;
const int UBSettings::defaultThumbnailWidth = 150;
开发者ID:xxbastekxx,项目名称:Sankore-3.1,代码行数:30,代码来源:UBSettings.cpp


注:本文中的QPen函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。