Cpper
C/C++高级工程师 Android高级软件工程师 IT集成工程师 音频工程师 熟悉c,c++,java,c#,py,js,asp等多种语言 程序猿

使用QGraphicsScene显示矩形框

int main(int argc, char *argv[])
{
    QApplication app(argc,argv);
    QGraphicsScene scene;
    scene.setSceneRect(
0,0,3000,3000);
    
    
for(int i=0;i<32;i++)
    {
        
for(int j=0;j<12;j++)
        {
            QGraphicsRectItem
* item = new QGraphicsRectItem(20+300*i,20+120*j,240,72);
            item
->setBrush(QColor(79,136,187,255));
            scene.addItem(item);
        }
    }
    
    QGraphicsView view(
&scene);
    view.setDragMode(QGraphicsView::ScrollHandDrag);
    view.resize(
600,540);
    view.show();

    
return app.exec();
}
posted @ 2015-12-09 18:14 ccsdu2009 阅读(429) | 评论 (0)编辑 收藏
 
     摘要: 最近想做个基于Opengl的GUI试了下SFML发现其String类对宽字节转换有问题,就修改了下String并重命名为Utf8使用这个应该可以正确显示中文该类修改如下:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->/////////////////...  阅读全文
posted @ 2015-11-20 13:09 ccsdu2009 阅读(535) | 评论 (0)编辑 收藏
 
import QtQuick 1.1

Text 
{
    Timer 
    {
        triggeredOnStart: 
true
        onTriggered: parent.text 
= Qt.formatTime(new Date())
        interval: 
1000; running: visible; repeat: true;
    }

    font.pixelSize: 
32
    font.family: 
"sans-serif"
    font.bold: 
true
    color: 
"#a1ff09"
}
posted @ 2015-11-04 11:43 ccsdu2009 阅读(752) | 评论 (0)编辑 收藏
 
import QtQuick 2.0
import QtQuick.Controls 
1.3  
import QtQuick.Window 
2.2  

ApplicationWindow 
{
    id: window 
    visible: 
true   
    title: qsTr(
"Hello World")  
    width: 
480  
    height: 
480  
    color: 
"#339546"
    property variant colorArray: [
"#00bde3","#67c111","#ea7025","#ef0748","#1894af"

    Column
    {
        id: flow
        spacing: 
2
        anchors.fill: parent

        Grid
        {
            anchors.margins: 
8
            spacing:
2
            Repeater
            {
                model: 
12
                Rectangle
                {
                    id: flag
                    width: 
120
                    height: 
0
                    property 
int colorIndex: Math.floor(Math.random()*5)
                    color: window.colorArray[colorIndex]
                    border.color: Qt.lighter(color)
                    Text
                    {
                        anchors.centerIn: parent
                        color: 
"#f0f0f0"
                        font.pixelSize: 
18
                        text: qsTr(
"WPS表单")
                    }

                    MouseArea 
                    {
                         anchors.fill: parent
                         onClicked: 
                         {
                             animateColor.start()
                             animateOpacity.start()
                         }
                    }

                    PropertyAnimation 
                    {
                         id: animateColor; 
                         target: flag; 
                         properties: 
"color"
                         to: 
"green"
                         duration: 
100
                    }

                    NumberAnimation 
                    {
                         id: animateOpacity
                         target: flag
                         properties: 
"opacity"
                         from: 
0.99
                         to: 
1.0
                         loops: Animation.Infinite
                         easing {type: Easing.OutBack; overshoot: 
500}
                    }

                    PropertyAnimation on height{to: 
24 ;duration:600; loops:Animation.Infinite }
                } 
            }
        }
        
        Rectangle
        {
            id: desc
            width: 
486
            height: 
0
            property 
int colorIndex: Math.floor(Math.random()*5)
            color: window.colorArray[colorIndex]
            border.color: Qt.lighter(color)
            
            Text
            {
                anchors.centerIn: parent
                color: 
"#f0f0f0"
                font.pixelSize: 
18
                text: qsTr(
"描述信息")
            }

            PropertyAnimation on height{to: 
32 ;duration:600; loops:Animation.Infinite }
        }

        Rectangle
        {
            id: detail
            width: 
486
            height: 
0
            property 
int colorIndex: Math.floor(Math.random()*5)
            color: window.colorArray[colorIndex]
            border.color: Qt.lighter(color)
            
            Text
            {
                id: text
                anchors.centerIn: parent
                color: 
"#f0f0f0"
                font.pixelSize: 
18
                text: qsTr(
"点击展开")
            }

            MouseArea  
            {  
                anchors.fill: parent  
   
                onReleased:
                {
                    text.text 
= row.visible == true ? qsTr("点击展开") : qsTr("点击折叠")
                    row.visible 
= row.visible == true ? false : true
                } 
            }  

            PropertyAnimation on height{to: 
32 ;duration:600; loops:Animation.Infinite }
        }  

        Row
        {
            id: row
            visible: 
false
            spacing: 
2
            
            Rectangle
            {
                id: d1
                width: 
120
                height: 
32
                property 
int colorIndex: Math.floor(Math.random()*5)
                color: window.colorArray[colorIndex]
                border.color: Qt.lighter(color)
                Text
                {
                    anchors.centerIn: parent
                    color: 
"#f0f0f0"
                    font.pixelSize: 
18
                    text: qsTr(
"WPS表单")
                }
            }
            Rectangle
            {
                id: d2
                width: 
120
                height: 
32
                property 
int colorIndex: Math.floor(Math.random()*5)
                color: window.colorArray[colorIndex]
                border.color: Qt.lighter(color)
                Text
                {
                    anchors.centerIn: parent
                    color: 
"#f0f0f0"
                    font.pixelSize: 
18
                    text: qsTr(
"WPS表单")
                }
            }
            Rectangle
            {
                id: d3
                width: 
120
                height: 
32
                property 
int colorIndex: Math.floor(Math.random()*5)
                color: window.colorArray[colorIndex]
                border.color: Qt.lighter(color)
                Text
                {
                    anchors.centerIn: parent
                    color: 
"#f0f0f0"
                    font.pixelSize: 
18
                    text: qsTr(
"WPS表单")
                }
            }
        }
    }

posted @ 2015-11-03 19:37 ccsdu2009 阅读(381) | 评论 (0)编辑 收藏
 
    bool unzip(const QString& in_file_path, const QString& out_file_path)  
    {  
        QuaZip archive(in_file_path);  
        
if (!archive.open(QuaZip::mdUnzip))  
            
return false;  
          
        QString path 
= out_file_path;  
        
if (!path.endsWith("/"&& !out_file_path.endsWith("\\"))  
            path 
+= "/";  
      
        QDir dir(out_file_path);  
        
if (!dir.exists())  
            dir.mkpath(out_file_path);  
      
        
forbool f = archive.goToFirstFile(); f; f = archive.goToNextFile() )  
        {  
            QString filePath 
= archive.getCurrentFileName();  
            QuaZipFile zFile(archive.getZipName(), filePath);  
            zFile.open(QIODevice::ReadOnly );  
            QByteArray ba 
= zFile.readAll();  
            zFile.close();  
      
            
if (filePath.endsWith("/"))  
            {  
                dir.mkpath(filePath);  
            }  
            
else  
            {  
                QFile dstFile(path 
+ filePath);  
                
if (!dstFile.open(QIODevice::WriteOnly))  
                    
return false;  
                dstFile.write(ba);  
                dstFile.close();  
            }  
        }  
      
        
return true;  
    }  

源于:
http://blog.csdn.net/kfbyj/article/details/13888101
证实可用.
posted @ 2015-10-16 16:33 ccsdu2009 阅读(1004) | 评论 (0)编辑 收藏
 
#include <QtCore/QCoreApplication>
#include 
<QTextStream>
#include 
<QXmlStreamReader>
#include 
<QtXML/QDom.h>
#include 
<QZip/QuaZipFile.h>
#include 
<iostream>

int main(int argc,char *argv[])
{
    QCoreApplication app(argc,argv);
    QuaZip zip(
":qrc/zip.zip");
    
if(!zip.open(QuaZip::mdUnzip))
    {
        std::cout
<<"open failed:"<<zip.getZipError()<<std::endl;
        system(
"pause");
        
return -1;
    }

    
if(zip.setCurrentFile("list.xml"))
    {
        QuaZipFile zipfile(
&zip);
        
if(!zipfile.open(QIODevice::ReadOnly))
        {
            std::cout
<<"open zipfile failed"<<std::endl;
            system(
"pause");
            
return -1;
        }

        QTextStream stream(
&zipfile);
        
while(!stream.atEnd())
            std::cout
<<qPrintable(stream.readLine())<<std::endl;

        zipfile.close();
        zip.close();
    }
    
else
        std::cout
<<"set current file failed."<<std::endl;
    system(
"pause");
    
return 1;
}

如上,需要使用QuaZip库
posted @ 2015-10-10 10:11 ccsdu2009 阅读(2637) | 评论 (0)编辑 收藏
 
本来打算使用QFtp,居然上传不成功

#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#ifdef WIN32
#include <io.h>
#else
#include <unistd.h>
#endif

#define REMOTE_URL      "sftp://account:password@xx.xx.xx.xx/"

static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{
    curl_off_t nread;
    size_t retcode = fread(ptr, size, nmemb, stream);
    nread = (curl_off_t)retcode;
    fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T " bytes from file\n", nread);
    return retcode;
}

int main(int argc,char *argv[])
{
    if(argc != 3)
    {
        printf("2 paramenters is needed.\n");
        return -1;
    
}

    char* local_file = argv[1];
    char* remote_file = argv[2];

    printf("call me for update -:%s,%s\n",local_file,remote_file);

    char remoteurl[1024] = 
{0};
    strcpy(remoteurl,REMOTE_URL);
    strcat(remoteurl,remote_file);

    CURL* curl;
    CURLcode res;
    FILE* file;
    struct stat file_info;
    curl_off_t fsize;

    if(stat(local_file,&file_info))
    
{
        printf("couldnt open '%s'
: %s\n", local_file, strerror(errno));
        return 1;
    
}

    fsize = (curl_off_t)file_info.st_size;
    printf("Local file size: %" CURL_FORMAT_CURL_OFF_T " bytes.\n", fsize);

    file = fopen(local_file, "rb");
    curl_global_init(CURL_GLOBAL_ALL);

    curl = curl_easy_init();

    if(curl)
    
{
        curl_easy_setopt(curl,CURLOPT_READFUNCTION,read_callback);
        curl_easy_setopt(curl,CURLOPT_UPLOAD,1L);
        curl_easy_setopt(curl,CURLOPT_URL,remoteurl);
        curl_easy_setopt(curl,CURLOPT_READDATA,file);
        curl_easy_setopt(curl,CURLOPT_INFILESIZE_LARGE,(curl_off_t)fsize);
        curl_easy_setopt(curl,CURLOPT_FTP_RESPONSE_TIMEOUT,120);
        res = curl_easy_perform(curl);
        if(res != CURLE_OK)
            fprintf(stderr,"curl_easy_perform() failed
: %s\n",curl_easy_strerror(res));
        curl_easy_cleanup(curl);
        fprintf(stderr,"finished update.");
    
}

    fclose(file);
    curl_global_cleanup();
    return 0;
}

以上代码经过实际测试.
posted @ 2015-08-31 17:21 ccsdu2009 阅读(1963) | 评论 (0)编辑 收藏
 
 -no-icu -no-opengl -confirm-license -opensource -nomake examples -nomake tests -mp -no-harfbuzz -no-angle -D _CRT_SECURE_NO_WARNINGS -skip qtactiveqt -skip qtandroidextras -skip qtconnectivity -skip qtdeclarative -skip qtenginio -skip qtgraphicaleffects -skip qtlocation -skip qtmacextras -skip qtquick1 -skip qtquickcontrols -skip qtscript -skip qtsensors -skip qtserialport -skip qtsvg -skip qtwebkit -skip qtwebkit-examples -skip qtx11extras -skip qtxmlpatterns
posted @ 2015-08-27 09:43 ccsdu2009 阅读(633) | 评论 (0)编辑 收藏
 
import QtQuick 2.0
import QtQuick.Particles 2.0

Rectangle 
{
    id
: root
    width: 480
; height: 360
    color: "#1f1f1f"
    ParticleSystem 
    {
        id: ps
    
}
    
    Emitter 
    
{
        id
: emitter
        anchors.left: parent.left
        anchors.verticalCenter: parent.verticalCenter
        width: 1
; height: 1
        system: ps
        emitRate: 10
        lifeSpan: 6400
        lifeSpanVariation: 600
        size: 32
        
        velocity: PointDirection 
        {
            x: 100
            y: 0
            xVariation: 0
            yVariation: 100/6
        
}
        
        acceleration: AngleDirection 
        
{
            angle
: 90
            magnitude: 30
        
}
    }
    ImageParticle 
    
{
        source
: "assets/ufo.png"
        system: ps
    
}
}
posted @ 2015-08-20 14:31 ccsdu2009 阅读(532) | 评论 (0)编辑 收藏
 
import QtQuick 2.2  
import QtQuick.Controls 1.1
    
Canvas
{
    id: root
    width: 200; height: 200
    onPaint:
    {
        var ctx = getContext("2d")
        ctx.lineWidth = 2
        ctx.strokeStyle = "blue"
        ctx.fillStyle = "red"
        ctx.beginPath()
            ctx.moveTo(50,50)
            ctx.lineTo(150,50)
            ctx.lineTo(150,150)
            ctx.lineTo(50,150)
        ctx.closePath()
        ctx.fillRect(10,10,10,10)
        ctx.strokeRect(20,20,10,10);
        ctx.fill()
        ctx.stroke()
    }
}
使用渐变
import QtQuick 2.2  
import QtQuick.Controls 1.1
    
Canvas
{
    id: root
    width: 200; height: 200
    onPaint:
    {
        var ctx = getContext("2d")
        var gradient = ctx.createLinearGradient(0,0,200,200)
        gradient.addColorStop(0,"blue")
        gradient.addColorStop(0.5,"red")
        gradient.addColorStop(1,"yellow")
        ctx.fillStyle = gradient
        ctx.fillRect(10,10,100,100)
    }
}
增加阴影
import QtQuick 2.2  
import QtQuick.Controls 1.1
    
Canvas
{
    id: root
    width: 200; height: 200
    onPaint:
    {
        var ctx = getContext("2d")
        ctx.shadowColor = "black";
        ctx.shadowOffsetX = 2;
        ctx.shadowOffsetY = 2;
        var gradient = ctx.createLinearGradient(0,0,200,200)
        gradient.addColorStop(0,"blue")
        gradient.addColorStop(0.5,"red")
        gradient.addColorStop(1,"yellow")
        ctx.fillStyle = gradient
        ctx.fillRect(10,10,100,100)
    }
}
posted @ 2015-08-20 14:11 ccsdu2009 阅读(569) | 评论 (0)编辑 收藏
仅列出标题
共38页: First 5 6 7 8 9 10 11 12 13 Last