Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How does a QML file set UTF-8 encoding?
Forum Updated to NodeBB v4.3 + New Features

How does a QML file set UTF-8 encoding?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
9 Posts 4 Posters 1.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mirro
    wrote on last edited by mirro
    #1
    QUrl source(“qrc:/qmlTest.qml”);
    QQuickWidget*  quickWidget = new QQuickWidget;
    quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView );
    quickWidget->setSource(source);
    
    
    import QtQuick 2.8
    import QtQuick.Controls 2.1
     
    Rectangle {
         id: mapWindow
         Text{
                 x:0
                 y:0
                 font.family:"Alibaba PuHuiTi"
                 font.pointSize:7
                 text:"test"
                 color:"#0AAAB1"
         }
     } 
    
    jsulmJ 1 Reply Last reply
    0
    • M mirro
      QUrl source(“qrc:/qmlTest.qml”);
      QQuickWidget*  quickWidget = new QQuickWidget;
      quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView );
      quickWidget->setSource(source);
      
      
      import QtQuick 2.8
      import QtQuick.Controls 2.1
       
      Rectangle {
           id: mapWindow
           Text{
                   x:0
                   y:0
                   font.family:"Alibaba PuHuiTi"
                   font.pointSize:7
                   text:"test"
                   color:"#0AAAB1"
           }
       } 
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @mirro Can you be more precise?
      Do you mean the encoding of the content of a QML source code file?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      0
      • jsulmJ jsulm

        @mirro Can you be more precise?
        Do you mean the encoding of the content of a QML source code file?

        M Offline
        M Offline
        mirro
        wrote on last edited by
        #3

        @jsulm said in How does a QML file set UTF-8 encoding?:

        a QML source code file

        Yes, i mean a QML source code file.

        jsulmJ KroMignonK 2 Replies Last reply
        0
        • M mirro

          @jsulm said in How does a QML file set UTF-8 encoding?:

          a QML source code file

          Yes, i mean a QML source code file.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @mirro The encoding of your sources depends on the editor configuration.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          1
          • jsulmJ jsulm

            @mirro The encoding of your sources depends on the editor configuration.

            M Offline
            M Offline
            mirro
            wrote on last edited by mirro
            #5

            @jsulm

            Why can't you upload an image using the following code?
            [img]https://s1.ax1x.com/2020/07/29/aZPKqe.png[/img]

            jsulmJ 1 Reply Last reply
            0
            • M mirro

              @jsulm

              Why can't you upload an image using the following code?
              [img]https://s1.ax1x.com/2020/07/29/aZPKqe.png[/img]

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @mirro Image upload does not always work here.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M mirro

                @jsulm said in How does a QML file set UTF-8 encoding?:

                a QML source code file

                Yes, i mean a QML source code file.

                KroMignonK Offline
                KroMignonK Offline
                KroMignon
                wrote on last edited by
                #7

                @mirro said in How does a QML file set UTF-8 encoding?:

                Yes, i mean a QML source code file.

                But is your QML file encoded as UTF-8?
                In Qt Creator look at the upper right corner of the editor View:
                206a6459-9396-40a7-813b-7a1cb7fa5613-image.png

                Or with menu Edit => Select Encoding... and choose UTF-8:
                fc7662cc-5414-4cce-9fc5-b9de2a2fe1a7-image.png

                You can also ensure always using UTF-8 with menu Tools => Options in Text Editor select Tab Behavior to select default encoding as UTF-8.

                It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                M 1 Reply Last reply
                2
                • KroMignonK KroMignon

                  @mirro said in How does a QML file set UTF-8 encoding?:

                  Yes, i mean a QML source code file.

                  But is your QML file encoded as UTF-8?
                  In Qt Creator look at the upper right corner of the editor View:
                  206a6459-9396-40a7-813b-7a1cb7fa5613-image.png

                  Or with menu Edit => Select Encoding... and choose UTF-8:
                  fc7662cc-5414-4cce-9fc5-b9de2a2fe1a7-image.png

                  You can also ensure always using UTF-8 with menu Tools => Options in Text Editor select Tab Behavior to select default encoding as UTF-8.

                  M Offline
                  M Offline
                  make2
                  wrote on last edited by make2
                  #8

                  @KroMignon , @jsulm
                  ce3f98a5-141a-4615-ac6c-ea830520ec89-image.png

                  I didn't describe it very well,
                  I use Qt Creator 4.15, how to show encoding format here? it is convenient

                  Edit1:

                  tool->options->text editor->display,
                  d0b23dfa-6526-49af-bb14-5510f980e1e8-image.png
                  I find that

                  jsulmJ 1 Reply Last reply
                  0
                  • M make2

                    @KroMignon , @jsulm
                    ce3f98a5-141a-4615-ac6c-ea830520ec89-image.png

                    I didn't describe it very well,
                    I use Qt Creator 4.15, how to show encoding format here? it is convenient

                    Edit1:

                    tool->options->text editor->display,
                    d0b23dfa-6526-49af-bb14-5510f980e1e8-image.png
                    I find that

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @make2 said in How does a QML file set UTF-8 encoding?:

                    how to show it?

                    The file you opened is not using UTF-8.
                    To make UTF-8 the default for source code files check the "Text Editor/Behaviour/Default Encoding" - it should be set to UTF-8.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved