Qml && Qt HTML Base64

10493 단어 Qt
Qt HTTP BASE64 + , , 。 :Base64UrlEncoding 

QString  TQmlHelper::add64(QVariant    data)
{


    QString  a = data.toByteArray().toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals).toStdString().c_str();
        qDebug()<<" :"<QString TQmlHelper::sub64(QVariant data)//는 base64에 가까운 암호화된 데이터입니다
{
QByteArray  a =  QByteArray::fromBase64(data.toByteArray(),QByteArray::Base64UrlEncoding QByteArray::OmitTrailingEquals); 
QString xx = QString::fromUtf8(a);
return xx;
}
Qt Text.RichText ,text HTML , BASE64 。 , , label HTTP , .
** BASE64

*** QML , QTextArea text :

 
<html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } style>head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">001p>body>html>
qml: A:PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMC8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9UUi9SRUMtaHRtbDQwL3N0cmljdC5kdGQiPgo8aHRtbD48aGVhZD48bWV0YSBuYW1lPSJxcmljaHRleHQiIGNvbnRlbnQ9IjEiIC8+PHN0eWxlIHR5cGU9InRleHQvY3NzIj4KcCwgbGkgeyB3aGl0ZS1zcGFjZTogcHJlLXdyYXA7IH0KPC9zdHlsZT48L2hlYWQ+PGJvZHkgc3R5bGU9IiBmb250LWZhbWlseTonU2ltU3VuJzsgZm9udC1zaXplOjlwdDsgZm9udC13ZWlnaHQ6NDAwOyBmb250LXN0eWxlOm5vcm1hbDsiPgo8cCBzdHlsZT0iIG1hcmdpbi10b3A6MHB4OyBtYXJnaW4tYm90dG9tOjBweDsgbWFyZ2luLWxlZnQ6MHB4OyBtYXJnaW4tcmlnaHQ6MHB4OyAtcXQtYmxvY2staW5kZW50OjA7IHRleHQtaW5kZW50OjBweDsiPjAwMTwvcD48L2JvZHk+PC9odG1sPg==,B:
<html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } style>head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">001p>body>html>
 Flickable {
        id: flickable
        x:offsetBeginX
        clip: true
        anchors.bottom: parent.bottom

        width: parent.width - btn.width -offsetBeginX-offsetendx
        height: btn.height
        TextArea.flickable: TextArea {

            id:edit
            text: ""
            placeholderText: " "
            wrapMode: TextArea.Wrap
            textFormat: TextEdit.RichText
            onCursorPositionChanged: {
                scrol.decrease()
            }
            onTextChanged: {
                setrect();
            }

            onFocusChanged: {
                if(focus == true)
                {
                    setrect()
                    cursorPosition = length


                }
            }

            function setrect() {
                if(contentHeight>btn.height)
                {
                    if(contentHeight<180)
                    {
                        flickable.height = contentHeight
                    }else
                    {
                        flickable.height = 180
                    }
                }

            }
        }

        ScrollBar.vertical: ScrollBar {
            id:scrol
            active: true
            pressed: true
            size: 1.0

        }
    }

온전한 데이터를 보내고 싶다면base64 인코딩을 제기해야 합니다

  Button{

        x:flickable.x+flickable.width + offsetendx
        anchors.bottom: parent.bottom
        id:btn
        text:" "
        font.bold: true
        font.pointSize: 14
        height: width*0.75
        width: 80
        onClicked: {

            All.webView.runJavaScript(" SendmessageToOne("+  "'"+  All. .zh+  "'"+  "," +"'"+ myapp.add64(edit.text)+"'"+")")
            msgmodel.append({txt:edit.text,org:1})
            msgroot.adjustIndex();
            reset();
            // 
        }
    }
// BASE64
      function  (msg)
        { 

            console.log(" :"+msg)
            console.log(" :"+myapp.sub64(msg))
            rootstatcktongxinj.currentItem.msgmodel.append({txt:myapp.sub64(msg),org:0})
            rootstatcktongxinj.currentItem.adjustIndex();

        }

좋은 웹페이지 즐겨찾기