xml version="1.0" encoding="utf-8" standalone="yes"12bet++博客-Cpperhttp://www.fometaux.com/gaimor/C/12bet高级工程师 Android高级软件工程师 IT集成工程师 音频工程师 熟悉c,12bet,java,c#,py,js,asp等多种语言 程序猿zh-cnSat, 24 Aug 2019 12:19:23 GMTSat, 24 Aug 2019 12:19:23 GMT6012bet++博客-Cpperhttp://www.fometaux.com/gaimor/archive/2019/08/23/216731.htmlccsdu2009ccsdu2009Fri, 23 Aug 2019 09:49:00 GMThttp://www.fometaux.com/gaimor/archive/2019/08/23/216731.htmlhttp://www.fometaux.com/gaimor/comments/216731.htmlhttp://www.fometaux.com/gaimor/archive/2019/08/23/216731.html#Feedback0http://www.fometaux.com/gaimor/comments/commentRss/216731.htmlhttp://www.fometaux.com/gaimor/services/trackbacks/216731.html#include <QString>
#include 
<QtPlugin>
#include 
<QObject>

struct AddonInfo
{
    QString name;
    QString description;
    QString version;
    QString author;
};

class AddonInterface : public QObject
{
    Q_OBJECT
public:
    
virtual ~AddonInterface() {}
    
virtual AddonInfo addonInfo()const { return AddonInfo(); }
};

Q_DECLARE_INTERFACE(AddonInterface,
"com.ppx.addon.interface/1.0")

class AddonInterfaceIMPL : public AddonInterface
{
    Q_OBJECT
public:
    AddonInfo addonInfo()
const;

#if QT_VERSION >= 0x050000
    Q_PLUGIN_METADATA(IID 
"com.ppx.addon.interface")
    Q_INTERFACES(AddonInterface);
#endif 
};

#include "addon.h"
#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2(FilterInterface,plugin)
#endif // QT_VERSION < 0x050000

AddonInfo AddonInterfaceIMPL::addonInfo()const
{
    AddonInfo addon;
    addon.name = "MyAddOn";
    addon.author = "Coder";
    addon.description = "Description";
    addon.version = "1.0";
    return addon;
}

使用
#include <qplugin.h>
#include <qpluginloader.h>
#include <qdebug>
#include "addon.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QPluginLoader loader("addon.dll");
    qDebug()<<"load plugin :"<<loader.load();

    auto object = loader.instance();
    qDebug() << "object:" << object;
    if (object)
    {
        AddonInterface* face = qobject_cast<AddonInterface*>(object);
        qDebug() << "face ptr:"<<face;
        auto info = face->addonInfo();
        qDebug() << info.author << " " << info.description << " " << info.name << " " << info.version;
    }

    return a.exec();
}



ccsdu2009 2019-08-23 17:49 发表评论
]]>
12bet++博客-Cpperhttp://www.fometaux.com/gaimor/archive/2019/08/22/216726.htmlccsdu2009ccsdu2009Thu, 22 Aug 2019 07:00:00 GMThttp://www.fometaux.com/gaimor/archive/2019/08/22/216726.htmlhttp://www.fometaux.com/gaimor/comments/216726.htmlhttp://www.fometaux.com/gaimor/archive/2019/08/22/216726.html#Feedback0http://www.fometaux.com/gaimor/comments/commentRss/216726.htmlhttp://www.fometaux.com/gaimor/services/trackbacks/216726.htmlimport QtQuick 2.4

Rectangle
{
    id: dragBackground
    visible: 
true
    color: 
"#dad1db"
    width:
720
    height:
480

    DragRectangle
    {
        z: 
10
        id:dragRectangle
        width: 
480
        height:
240

        Component.onCompleted:
        {
             dragBackground.makeViewCenter(dragRectangle)
        }
    }

    
function makeViewCenter(view)
    {
        
var cx = (width-view.width)*0.5
        
var cy = (height-view.height)*0.5
        view.x 
= cx
        view.y 
= cy
    }
}

Rectangle
import QtQuick 2.0

Rectangle
{
    id:resizeRectangle
    property int enableSize: 12
    property bool isPressed: false
    property point customPoint
    color: "#00debff3"
    border.color: "#d37e49"
    readonly property int minWidth: 64
    readonly property int minHeight: 64

    MouseArea
    {
        id: mouseArea
        anchors.fill: resizeRectangle
        drag.target: parent

        onWheel:
        {
            var diff_w = 0.0
            var diff_h = 0.0

            if(wheel.angleDelta.y > 0)
            {
                diff_w = resizeRectangle.width * 0.02
                diff_h = resizeRectangle.height * 0.02
            }
            else if(wheel.angleDelta.y < 0)
            {
                diff_w = -resizeRectangle.width * 0.02
                diff_h = -resizeRectangle.height * 0.02
            }
            else
            {
                resizeRectangle.width = width
                resizeRectangle.height = height
            }

            fixedRetangle(diff_w,diff_h)

            drag.minimumX = 0
            drag.maximumX = dragBackground.width - resizeRectangle.width
            drag.minimumY = 0
            drag.maximumY = dragBackground.height - resizeRectangle.height
        }
    }

    Item
    {
        id: leftTop
        width: enableSize
        height: enableSize
        anchors.left: parent.left
        anchors.top: parent.top

        MouseArea
        {
            anchors.fill: parent
            hoverEnabled: true

            onPressed: press(mouse)
            onEntered: enter(1)
            onReleased: release()
            onPositionChanged: positionChange(mouse, -1, -1)
        }
    }

    Item
    {
        id: top
        height: enableSize
        anchors.left: leftTop.right
        anchors.right: rightTop.left
        anchors.top: parent.top

        MouseArea
        {
            anchors.fill: parent
            hoverEnabled: true

            onPressed: press(mouse)
            onEntered: enter(2)
            onReleased: release()
            onMouseYChanged: positionChange(Qt.point(customPoint.x, mouseY), 1, -1)
        }
    }

    Item
    {
        id: rightTop
        width: enableSize
        height: enableSize
        anchors.right: parent.right
        anchors.top: parent.top

        MouseArea
        {
            anchors.fill: parent
            hoverEnabled: true

            onPressed: press(mouse)
            onEntered: enter(3)
            onReleased: release()
            onPositionChanged: positionChange(mouse, 1, -1)
        }
    }

    Item
    {
        id: left
        width: enableSize
        anchors.left: parent.left
        anchors.top: leftTop.bottom
        anchors.bottom: leftBottom.top

        MouseArea
        {
            anchors.fill: parent
            hoverEnabled: true

            onPressed: press(mouse)
            onEntered: enter(4)
            onReleased: release()

            onMouseXChanged: positionChange(Qt.point(mouseX, customPoint.y), -1, 1)
        }
    }

    Item
    {
        id: center
        anchors.left: left.right
        anchors.right: right.left
        anchors.top: top.bottom
        anchors.bottom: bottom.top

        MouseArea
        {
            anchors.fill: parent
            property point clickPos

            onPressed: clickPos = Qt.point(mouse.x,mouse.y)
            onPositionChanged:
            {
                if(pressed)
                {
                    var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)
                    resizeRectangle.x += delta.x
                    resizeRectangle.y += delta.y
                    fixedRetangle(0,0)
                }
            }
        }
    }

    Item
    {
        id: right
        width: enableSize
        anchors.right: parent.right
        anchors.top: rightTop.bottom
        anchors.bottom: rightBottom.top

        MouseArea
        {
            anchors.fill: parent
            hoverEnabled: true

            onPressed: press(mouse)
            onEntered: enter(6)
            onReleased: release()
            onMouseXChanged: positionChange(Qt.point(mouseX, customPoint.y), 1, 1)
        }
    }

    Item
    {
        id: leftBottom
        width: enableSize
        height: enableSize
        anchors.left: parent.left
        anchors.bottom: parent.bottom

        MouseArea
        {
            anchors.fill: parent
            hoverEnabled: true

            onPressed: press(mouse)
            onEntered: enter(7)
            onReleased: release()
            onPositionChanged: positionChange(mouse, -1, 1)
        }
    }

    Item
    {
        id: bottom
        height: enableSize
        anchors.left: leftBottom.right
        anchors.right: rightBottom.left
        anchors.bottom: parent.bottom

        MouseArea
        {
            anchors.fill: parent
            hoverEnabled: true

            onPressed: press(mouse)
            onEntered: enter(8)
            onReleased: release()
            onMouseYChanged: positionChange(Qt.point(customPoint.x, mouseY), 1, 1)
        }
    }

    Item
    {
        id:rightBottom
        width: enableSize
        height: enableSize
        anchors.right: parent.right
        anchors.bottom: parent.bottom

        MouseArea
        {
            anchors.fill: parent
            hoverEnabled: true

            onPressed: press(mouse)
            onEntered: enter(9)
            onReleased: release()

            onPositionChanged: positionChange(mouse,1,1)
        }
    }

    function fixedRetangle(dx,dy)
    {
        if(resizeRectangle.width <= minWidth && resizeRectangle.height <= minHeight && dx <=0 && dy <= 0)
            return

        resizeRectangle.x -= dx*0.5
        resizeRectangle.y -= dy*0.5
        resizeRectangle.width += dx
        resizeRectangle.height += dy

        if(resizeRectangle.width < minWidth)
            resizeRectangle.width = minWidth
        if(resizeRectangle.height < minHeight)
            resizeRectangle.height = minHeight

        if(resizeRectangle.width > dragBackground.width)
            resizeRectangle.width = dragBackground.width
        if(resizeRectangle.height > dragBackground.height)
            resizeRectangle.height = dragBackground.height

        if(resizeRectangle.width + resizeRectangle.x > dragBackground.width)
            resizeRectangle.x = dragBackground.width - resizeRectangle.width
        if(resizeRectangle.height + resizeRectangle.y > dragBackground.height)
            resizeRectangle.y = dragBackground.height - resizeRectangle.height

        if(resizeRectangle.y < 0)
            resizeRectangle.y = 0

        if(resizeRectangle.x < 0)
            resizeRectangle.x = 0
    }

    function enter(direct)
    {
    }

    function press(mouse)
    {
        isPressed = true
        customPoint = Qt.point(mouse.x, mouse.y)
    }

    function release()
    {
        isPressed = false
    }

    function positionChange(newPosition,directX, directY)
    {
        if(!isPressed)
            return

        var delta = Qt.point(newPosition.x-customPoint.x, newPosition.y-customPoint.y)
        var tmpW,tmpH

        if(directX >= 0)
            tmpW = resizeRectangle.width + delta.x
        else
            tmpW = resizeRectangle.width - delta.x

        if(directY >= 0)
            tmpH = resizeRectangle.height + delta.y
        else
            tmpH = resizeRectangle.height - delta.y

        if(tmpW < resizeRectangle.minimumWidth)
        {
            if(directX < 0)
                resizeRectangle.x += (resizeRectangle.width - resizeRectangle.minimumWidth)
            resizeRectangle.width = resizeRectangle.minimumWidth
        }
        else
        {
            resizeRectangle.width = tmpW
            if(directX < 0)
                resizeRectangle.x += delta.x
        }

        if(tmpH < resizeRectangle.minimumHeight)
        {
            if(directY < 0)
                resizeRectangle.y += (resizeRectangle.height - resizeRectangle.minimumHeight)
            resizeRectangle.height = resizeRectangle.minimumHeight
        }
        else
        {
            resizeRectangle.height = tmpH
            if(directY < 0)
                resizeRectangle.y += delta.y
        }

        fixedRetangle(0,0)
    }
}



ccsdu2009 2019-08-22 15:00 发表评论
]]>
12bet++博客-Cpperhttp://www.fometaux.com/gaimor/archive/2019/08/22/216725.htmlccsdu2009ccsdu2009Thu, 22 Aug 2019 03:49:00 GMThttp://www.fometaux.com/gaimor/archive/2019/08/22/216725.htmlhttp://www.fometaux.com/gaimor/comments/216725.htmlhttp://www.fometaux.com/gaimor/archive/2019/08/22/216725.html#Feedback0http://www.fometaux.com/gaimor/comments/commentRss/216725.htmlhttp://www.fometaux.com/gaimor/services/trackbacks/216725.htmlvoid adjustImageHSL(QImage& image,qreal hue,qreal saturation,qreal lightness)
{
    unsigned 
int* data = (unsigned int*)image.bits();
    
int size = image.width()*image.height();
    QColor color;

    
for(int i = 0; i < size; i++)
    {
        
int red = qRed(data[i]);
        
int green = qGreen(data[i]);
        
int blue = qBlue(data[i]);
        color.setRed(red);
        color.setGreen(green);
        color.setBlue(blue);
        qreal h 
= color.hueF() + hue;
        qreal s 
= color.saturationF() + saturation;
        qreal l 
= color.lightnessF() + lightness;
        h 
= qBound<qreal>(0,h,1);
        s 
= qBound<qreal>(0,s,1);
        l 
= qBound<qreal>(0,l,1);
        color.setHslF(h,s,l);
        color.setAlpha(qAlpha(data[i]));
        data[i] 
= qRgba(color.red(),color.green(),color.blue(),color.alpha());
    }

    
return;
}


ccsdu2009 2019-08-22 11:49 发表评论
]]>
12bet++博客-Cpperhttp://www.fometaux.com/gaimor/archive/2019/08/21/216719.htmlccsdu2009ccsdu2009Wed, 21 Aug 2019 07:58:00 GMThttp://www.fometaux.com/gaimor/archive/2019/08/21/216719.htmlhttp://www.fometaux.com/gaimor/comments/216719.htmlhttp://www.fometaux.com/gaimor/archive/2019/08/21/216719.html#Feedback0http://www.fometaux.com/gaimor/comments/commentRss/216719.htmlhttp://www.fometaux.com/gaimor/services/trackbacks/216719.htmlimport QtQuick 2.4
import QtQuick.Controls 
2.4
import QtQuick.Layouts 
1.3
import QtQuick.Dialogs 
1.2

Popup
{
    width: 
360
    height: 
90
    modal: 
true
    focus: 
true
    opacity: 
0.96

    
function setWarningText(input)
    {
        warningText.text 
= input
    }

    Text
    {
        id:warningText
        anchors.centerIn: parent
        text: 
"WarningText"
    }
}


ccsdu2009 2019-08-21 15:58 发表评论
]]>
12bet++博客-Cpperhttp://www.fometaux.com/gaimor/archive/2019/08/20/216716.htmlccsdu2009ccsdu2009Tue, 20 Aug 2019 05:53:00 GMThttp://www.fometaux.com/gaimor/archive/2019/08/20/216716.htmlhttp://www.fometaux.com/gaimor/comments/216716.htmlhttp://www.fometaux.com/gaimor/archive/2019/08/20/216716.html#Feedback0http://www.fometaux.com/gaimor/comments/commentRss/216716.htmlhttp://www.fometaux.com/gaimor/services/trackbacks/216716.htmlimport QtQuick 2.9

Item
{
    visible: 
true
    width: 
1620
    height: 
720
    id:background

    Image
    {
        source: 
"images/2560.png"
        anchors.fill: parent
    }

    Flickable
    {
        id: flick
        anchors.top: parent.top;
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.bottom: parent.bottom
        anchors.margins: 
3
        contentWidth: 
0
        contentHeight: 
0
        clip: 
true

        Image
        {
            id: image
            smooth: 
true
            transformOrigin: Item.Center
            source:
"mark.png"

            onStatusChanged:
            {
                
if(status === Image.Ready)
                {
                    image.width 
*= 0.5
                    image.height 
*= 0.5

                    image.x 
= background.width*0.5-0.5*image.width
                    image.y 
= background.height*0.5-0.5*image.height

                    
/*mouseArea.drag.minimumX = 0
                    mouseArea.drag.maximumX = flick.width - image.width
                    mouseArea.drag.minimumY = 0
                    mouseArea.drag.maximumY = flick.height - image.height
*/
                }
            }
        }
    }

    
function makeImageCenter(imageWidth,imageHeight)
    {
        
var cx = image.x + 0.5*image.width
        
var cy = image.y + 0.5*image.height

        image.width 
= imageWidth
        image.height 
= imageHeight

        image.x 
= cx - image.width*0.5
        image.y 
= cy - image.height*0.5
    }

    MouseArea
    {
        id: mouseArea
        anchors.fill: flick
        drag.target: image

        onWheel:
        {
            
var diff_w = 0.0
            
var diff_h = 0.0

            
if(wheel.angleDelta.y > 0)
            {
                diff_w 
= image.width * 0.02
                diff_h 
= image.height * 0.02
            }
            
else if(wheel.angleDelta.y < 0)
            {
                diff_w 
= -image.width * 0.02
                diff_h 
= -image.height * 0.02
            }
            
else
            {
                image.width 
= width
                image.height 
= height
            }

            
if(wheel.angleDelta.y != 0)
                background.makeImageCenter(image.width
+diff_w,image.height+diff_h)

            drag.minimumX 
= 0
            drag.maximumX 
= flick.width - image.width
            drag.minimumY 
= 0
            drag.maximumY 
= flick.height - image.height
        }
    }
}


ccsdu2009 2019-08-20 13:53 发表评论
]]>
12bet++博客-Cpperhttp://www.fometaux.com/gaimor/archive/2019/08/19/216710.htmlccsdu2009ccsdu2009Mon, 19 Aug 2019 05:42:00 GMThttp://www.fometaux.com/gaimor/archive/2019/08/19/216710.htmlhttp://www.fometaux.com/gaimor/comments/216710.htmlhttp://www.fometaux.com/gaimor/archive/2019/08/19/216710.html#Feedback0http://www.fometaux.com/gaimor/comments/commentRss/216710.htmlhttp://www.fometaux.com/gaimor/services/trackbacks/216710.htmlvoid buildTreeItem(QObjectList* list,QStandardItem* item)
{
    
foreach(auto object,*list)
    {
        auto current 
= new QStandardItem();
        current
->setText(object->objectName());
        item
->appendRow(current);
        auto chidren 
= object->children();
        
if(!chidren.isEmpty())
            buildTreeItem(
&chidren,current);
    }
}

void buildTree(QTreeView* view,const QList<QObject*>& list)
{
    view
->header()->hide();
    view
->setColumnHidden(0,true);
    QStandardItemModel
* model = new QStandardItemModel(view);
    
foreach(auto object,list)
    {
        auto item 
= new QStandardItem(object->objectName());
        auto list 
= object->children();
        buildTreeItem(
&list,item);
        model
->appendRow(item);
    }
    view
->setModel(model);
}

QObject
* buildObjectTree(QObject* parent,const QString& text)
{
    auto 
object = new QObject(parent);
    
object->setObjectName(text);
    
return object;
}



    QWidget widget;
    auto box 
= new QVBoxLayout();
    widget.setLayout(box);
    QTreeView
* tree = new QTreeView(&widget);
    box
->addWidget(tree);

    QList
<QObject*> list;
    auto 
object = buildObjectTree(nullptr,"1");

    list.append(
object);
    
    buildObjectTree(
object"2");
    buildObjectTree(
object"3");
    
object = buildObjectTree(object"4");
    buildObjectTree(
object"5");
    buildObjectTree(
object"6");
    
object = buildObjectTree(object"7");

    buildObjectTree(
object"8");
    buildObjectTree(
object"9");
    buildObjectTree(
object"10");
    buildObjectTree(
object"11");
    
    buildTree(tree,list);
    widget.show();


ccsdu2009 2019-08-19 13:42 发表评论
]]>
12bet++博客-Cpperhttp://www.fometaux.com/gaimor/archive/2019/08/16/216697.htmlccsdu2009ccsdu2009Fri, 16 Aug 2019 04:14:00 GMThttp://www.fometaux.com/gaimor/archive/2019/08/16/216697.htmlhttp://www.fometaux.com/gaimor/comments/216697.htmlhttp://www.fometaux.com/gaimor/archive/2019/08/16/216697.html#Feedback0http://www.fometaux.com/gaimor/comments/commentRss/216697.htmlhttp://www.fometaux.com/gaimor/services/trackbacks/216697.htmlstatic QObject* cpp_qobject_singletontype_provider(QQmlEngine* engine,QJSEngine* scriptEngine)
{
    Q_UNUSED(engine)
    Q_UNUSED(scriptEngine)
    return cppobject;
}

qmlRegisterSingletonType<CppObject>("cppobject", 1, 0, "CppObject",cppobject_qobject_singletontype_provider);


ccsdu2009 2019-08-16 12:14 发表评论
]]>
12bet++博客-Cpperhttp://www.fometaux.com/gaimor/archive/2019/08/15/216692.htmlccsdu2009ccsdu2009Thu, 15 Aug 2019 01:40:00 GMThttp://www.fometaux.com/gaimor/archive/2019/08/15/216692.htmlhttp://www.fometaux.com/gaimor/comments/216692.htmlhttp://www.fometaux.com/gaimor/archive/2019/08/15/216692.html#Feedback0http://www.fometaux.com/gaimor/comments/commentRss/216692.htmlhttp://www.fometaux.com/gaimor/services/trackbacks/216692.html    qml = new QQuickWidget();
    setLayout(box);

    qml->setResizeMode(QQuickWidget::SizeRootObjectToView);
    qml->setClearColor(Qt::gray);

    QMLObjectInterface* face = new QMLObjectInterface(this);
    qml->engine()->rootContext()->setContextProperty("cplusplusObject",face);

    qml->setSource(QUrl("QML.qml"));
    foreach(auto error, qml->errors())
        qDebug() << "error:" << error;

    auto object = qml->rootObject();
    object->setProperty("width",480);
   
    auto items = object->findChildren<QQuickItem*>("button");
   
    if (!items.isEmpty())
        items[0]->setProperty("text",QStringLiteral("按键"));
 

    box->addWidget(qml);
QML
import QtQuick 2.11
import QtQuick.Controls 2.1
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.3
import QtQuick.Window 2.11
import "qmls" as QMLS
import cplusplus 1.0

Rectangle
{
    id: base
    width:640
    height:480

    ColumnLayout
    {
        anchors.fill:parent
        anchors.margins: 6
        spacing: 4

        Rectangle
        {
            id:image
            Layout.fillWidth: true
            Layout.fillHeight: true
            color:"#cdcdc0"

            TextEdit
            {
                id:text
                anchors.centerIn: parent
                width:parent.width
                text:"请点击下方按键"
                verticalAlignment: Text.AlignVCenter
                horizontalAlignment: Text.AlignHCenter
                wrapMode: Text.WordWrap
                font.pointSize: 12
            }
        }

        RowLayout
        {
            Rectangle
            {
                Layout.fillWidth: true
            }

            Button
            {
                id:button
                property int index: 0
                property string buttonText:"Click"
                text:buttonText
                objectName: "button"
                onClicked:
                {
                    text.text = cplusplusObject.getString()
                }
            }

        }
    }
}


ccsdu2009 2019-08-15 09:40 发表评论
]]>
12bet++博客-Cpperhttp://www.fometaux.com/gaimor/archive/2019/08/14/216687.htmlccsdu2009ccsdu2009Wed, 14 Aug 2019 09:46:00 GMThttp://www.fometaux.com/gaimor/archive/2019/08/14/216687.htmlhttp://www.fometaux.com/gaimor/comments/216687.htmlhttp://www.fometaux.com/gaimor/archive/2019/08/14/216687.html#Feedback0http://www.fometaux.com/gaimor/comments/commentRss/216687.htmlhttp://www.fometaux.com/gaimor/services/trackbacks/216687.htmlimport QtQuick 2.11
import QtQuick.Controls 2.1
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.3
import QtQuick.Window 2.11
import cplusplus 1.0

Rectangle
{
    id: base
    width:640
    height:480

    ColumnLayout
    {
        anchors.fill:parent
        anchors.margins: 6
        spacing: 4

        Rectangle
        {
            id:image
            Layout.fillWidth: true
            Layout.fillHeight: true
            color:"#cdcdc0"

            TextEdit
            {
                id:text
                anchors.centerIn: parent
                width:parent.width
                text:"请点击下方按键"
                verticalAlignment: Text.AlignVCenter
                horizontalAlignment: Text.AlignHCenter
                wrapMode: Text.WordWrap
                font.pointSize: 12
            }
        }

        RowLayout
        {
            Rectangle
            {
                Layout.fillWidth: true
            }

            Button
            {
                property int index: 0
                text:"点击"

                onClicked:
                {
                    text.text = cplusplusObject.getString()
                }
            }

        }
    }
}



ccsdu2009 2019-08-14 17:46 发表评论
]]>
12bet++博客-Cpperhttp://www.fometaux.com/gaimor/archive/2019/08/14/216686.htmlccsdu2009ccsdu2009Wed, 14 Aug 2019 08:02:00 GMThttp://www.fometaux.com/gaimor/archive/2019/08/14/216686.htmlhttp://www.fometaux.com/gaimor/comments/216686.htmlhttp://www.fometaux.com/gaimor/archive/2019/08/14/216686.html#Feedback0http://www.fometaux.com/gaimor/comments/commentRss/216686.htmlhttp://www.fometaux.com/gaimor/services/trackbacks/216686.html ListView
        {
            id: view
            orientation: Qt.Horizontal
            Layout.fillWidth: true
            height:64
            //model: 180
            spacing: -24
            clip: true

            delegate: Rectangle
            {
                width: 50
                height: parent.height

                Image
                {
                    id:imageItem
                    width:64
                    height:64
                    anchors.centerIn: parent
                    source:getFileName(index*Math.floor(2560/180))
                    property int current: 0

                    onSourceChanged:
                    {
                        current = index;
                    }

                    MouseArea
                    {
                        id: mouseArea
                        anchors.fill: parent
                        onClicked:
                        {
                            var filename = getFileName(Math.floor(2560/180)*imageItem.current)
                            image.source = filename
                        }
                    }
                }

                function getFileName(index)
                {
                    return "images/"+index+".png"
                }
            }
        }


ccsdu2009 2019-08-14 16:02 发表评论
]]>