10 Nisan 2018 Salı

Qwt2 Canvas ve iki nokta arası mesafe ölçme (canvas, distance picker,scatter point)

    // canvas tanımlanıyor 
    canvas()->setStyleSheet(
        "border: 2px solid Black;"
        "border-radius:55px;"
        "background-color: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1,"
            "stop: 0 LemonChiffon, stop: 1 PaleGoldenrod );"
    );

    // attach curve
    
    // Boyama Nesnesi tanımlanıyor 
    d_curve = new QwtPlotCurve( "Scattered Points" );
    d_curve->setPen( QColor( "Orange" ) );

    // when using QwtPlotCurve::ImageBuffer simple dots can be
    // rendered in parallel on multicore systems.
    // render ediliyor 
    d_curve->setRenderThreadCount( 0 ); // 0: use QThread::idealThreadCount()

    d_curve->attach( this );

    // cizim icin herhangi bir sembol tanımlanmıyor )
    setSymbol( NULL );

    // panning with the left mouse button
    
    // canvas kaydırılabilir yapılıyor 
    (void )new QwtPlotPanner( canvas() );

    // zoom in/out with the wheel
    // mouse topu ile zoomlama aktif ediliyor 
    QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas() );
    magnifier->setMouseButton( Qt::NoButton );

    // distanve measurement with the right mouse button
    //mouseun sag buttonu ile iki nokta arası mesafe ölçülüebiliyor
    DistancePicker *picker = new DistancePicker( canvas() );
    picker->setMousePattern( QwtPlotPicker::MouseSelect1, Qt::RightButton );

    picker->setRubberBandPen( QPen( Qt::blue ) );








Share:

Qwt ile Koordinatları Çizme ve Boyama(QwtPlot,QwtPlotGrid,QwtPlotCurve Kullanımı)

    QwtPlot plot;
    plot.setTitle( "Plot Demo" );    //baslık adı
    plot.setCanvasBackground( Qt::white );   // arka plan rengi
    plot.setAxisScale( QwtPlot::yLeft, 0.0, 2.0 );   // y eksenin degerleri
    plot.insertLegend( new QwtLegend() );   // plota tanımlayıcı legend ekleme

    QwtPlotGrid *grid = new QwtPlotGrid();   // Plota ızgara ekleme 
    grid->attach( &plot );

    QwtPlotCurve *curve = new QwtPlotCurve();  // Plotu boyamak ve boyanan özelligin adı  ve renginin tanımlanması 
    curve->setTitle( "Some Points" );
    curve->setPen( Qt::blue,100);
    curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
    
    QPolygonF points;     // cizilecek poligon noktaları 
    points << QPointF( 0,0.5 ) << QPointF( 1, 0.5 ) << QPointF( 2.0,0.5 ) << QPointF( 3.0,0.5)   << QPointF( 4.0, 0.5) << QPointF( 5.0,0.5)  << QPointF( 6.0, 0.5) << QPointF( 7.0,0.5); 
    curve->setSamples( points );    // noktaların  boyama nesnesine atanması 
    curve->attach( &plot );   // boyama nesnesinin plota eklenmesi 

Share:

21 Mart 2018 Çarşamba

Qml Keynavigation Examples // Trafik lambası

   Rectangle {
        id: left
        x: 25
        y: 25
        width: 150
        height: 150
        color: focus ? "red" : "darkred"         
        KeyNavigation.right: right
        focus: true
    }
    Rectangle {
        id: right
        x: 225
        y: 25
        width: 150
        height: 150
        color: focus ? "green" : "darkgreen"
        KeyNavigation.left: left

    }


Yön tusu ile saga basınca sag acık yeşil , sola basınca sol acık kırmızı olarak değişir 



Share:

Qml KeyNavigaiton Examples

 TextInput {
        id: name
        text: "name"
        focus: true
        KeyNavigation.tab: adress
    }
    TextInput {
        id: adress
        text: "addressss"
        KeyNavigation.backtab: name

    }
Share:

QML Mouse Area Examples 3

  Text {
        id: title
        text: qsTr("Qt Quick ")
        x: 50
        y: 25
        font.family: "Helvetica"
        font.pixelSize: 50
        MouseArea {
            anchors.fill: parent
            onPressed: parent.color = "green"
            onReleased: parent.color = "red"
        }
    }
    Rectangle {
        x: 50
        y: 200
        width: 100
        height: 50
        color: mouse_area.containsMouse ? "blue" : "orange"
        MouseArea {
            id: mouse_area
            anchors.fill: parent
            hoverEnabled: true
        }
    }
Share:

QML Position Example 2

Image {
    source: {
        if (Screen.PixelDensity < 40)
        "image_low_dpi.png"
        else if (Screen.PixelDensity > 300)      // Pixele göre resim kullanılıyor 
        "image_high_dpi.png"
        else
        "image.png"
        }
    }
Share:

QML Position Examples

ApplicationWindow {
    id: root
    visible: true
    width: 480
    height: 620

    GridLayout {
        anchors.fill: parent
        anchors.margins: 20
        rowSpacing: 20
        columnSpacing: 20
        flow:  width > height ? GridLayout.LeftToRight : GridLayout.TopToBottom  // IMPORTANT 
        Rectangle {
            Layout.fillWidth: true
            Layout.fillHeight: true
            color: "#5d5b59"
            Label {
                anchors.centerIn: parent
                text: "Top or left"
                color: "white"
            }
        }
        Rectangle {
            Layout.fillWidth: true
            Layout.fillHeight: true
            color: "#1e1b18"
            Label {
                anchors.centerIn: parent
                text: "Bottom or right"
                color: "white"
            }
        }
    }
}
Share: