Results 1 to 4 of 4

Thread: Grid Minor Major and gap before the data

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Posts
    22
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Grid Minor Major and gap before the data

    Hi,
    This is the code in the constructor :
    Qt Code:
    1. PlotWidget::PlotWidget(QWidget * parent, double * _ySession,
    2. QString name, int rate, int numVis, int numSess)
    3. : QwtPlot(parent) {
    4. // data stuff....
    5.  
    6. QwtPainter::setDeviceClipping(false);
    7. canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, true);
    8. canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, true);
    9. //canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
    10. canvas()->setFrameStyle(QFrame::Box | QFrame::Plain);
    11. canvas()->setLineWidth(1);
    12. canvas()->setMidLineWidth(0);
    13. setCanvasBackground(QColor(Qt::white));
    14. enableAxis(QwtPlot::xBottom, false);
    15. enableAxis(QwtPlot::yLeft, false);
    16. setMargin(0);
    17.  
    18. setAxisScale(QwtPlot::xBottom,0.0, sizeLoop);
    19. setAxisScale(QwtPlot::yLeft,1500, 3000, 0 );
    20.  
    21. setAxisMaxMajor(QwtPlot::yLeft, 8);
    22. setAxisMaxMinor(QwtPlot::yLeft, 5);
    23.  
    24. QwtValueList vlist[3];
    25. for(double i=0;i<sizeLoop; i+=((sizeLoop-0)/13*5))
    26. vlist[0] << i;
    27. for(double i=0;i<sizeLoop; i+=((sizeLoop-0)/13))
    28. vlist[1] << i;
    29. for(double i=0;i<sizeLoop; i+=((sizeLoop-0)/13))
    30. vlist[2] << i;
    31. QwtScaleDiv scdiv(0, sizeLoop, vlist);
    32. setAxisScaleDiv(QwtPlot::xBottom, scdiv);
    33.  
    34. // for inside margin (I think)
    35. axisScaleEngine(QwtPlot::xBottom)->setAttributes(QwtScaleEngine::Floating);
    36. axisScaleEngine(QwtPlot::xTop)->setAttributes(QwtScaleEngine::Floating);
    37. axisScaleEngine(QwtPlot::yLeft)->setAttributes(QwtScaleEngine::Floating);
    38. axisScaleEngine(QwtPlot::yRight)->setAttributes(QwtScaleEngine::Floating);
    39.  
    40. curve = new QwtPlotCurve(name);
    41. //curve->setRenderHint(QwtPlotItem::RenderAntialiased);
    42. pen->setWidthF(penWidth + penWidthDiff);
    43. curve->setPen(*pen);
    44. curve->attach(this);
    45. curve->setRawData(xLoop, yLoop, sizeLoop);
    46.  
    47. grid = new QwtPlotGrid;
    48. grid->enableXMin(true);
    49. grid->enableYMin(true);
    50. gridMinPen = new QPen(QColor(255, 230, 230), 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    51. gridMajPen = new QPen(QColor(255, 200, 200), 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    52. grid->setMajPen(*gridMajPen);
    53. grid->setMinPen(*gridMinPen);
    54. grid->attach(this);
    55. }
    To copy to clipboard, switch view to plain text mode 

    And the code in the derived print filter :
    Qt Code:
    1. QColor MyQwtPlotPrintFilter::color(const QColor &c, Item item) const {
    2. switch(item){
    3. case MajorGrid:
    4. return Qt::blue;
    5. case MinorGrid:
    6. return Qt::green;
    7. default:;
    8. }
    9. return c;
    10. }
    To copy to clipboard, switch view to plain text mode 

    I got the exported pdf as attached "export.pdf". But I want to get "expected.png".
    I added the colors to see the major and minor grids.

    Now, the problem is :
    1) I cannot see the minor grids at x axis.
    2) I dont want a gap between the starting data and plot edge.

    For 2'nd I found :
    axisScaleEngine(QwtPlot::xBottom)->setAttributes(QwtScaleEngine::Floating);
    but I couldn't realize what the QwtScaleEngine::Floating means (and other Attribute's)

    Thanks for help.


    Hüseyin
    Attached Images Attached Images
    Attached Files Attached Files

Similar Threads

  1. Best way to display lots of data fast
    By New2QT in forum Newbie
    Replies: 4
    Last Post: 16th October 2008, 22:46
  2. Replies: 7
    Last Post: 29th August 2008, 10:24
  3. Replies: 4
    Last Post: 19th October 2007, 19:47
  4. Data model
    By steg90 in forum Qt Programming
    Replies: 3
    Last Post: 17th September 2007, 12:14
  5. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.