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. insert basic code source and run it

insert basic code source and run it

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 3 Posters 1.2k 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.
  • S Offline
    S Offline
    signalK
    wrote on last edited by
    #1

    Hi,

    My goal is to copy / paste source code of basic functions in order to understand, to study their single effect
    So,how (type of project) then insert, compile run basic source code in a new project?

    thanks

    1 Reply Last reply
    0
    • KillerSmathK Offline
      KillerSmathK Offline
      KillerSmath
      wrote on last edited by KillerSmath
      #2

      @signalK
      Hi there.
      If you are interested in learn QML, i can suggest you a good eBook to start your learning.

      https://qmlbook.github.io/ <- Qt5 Cadaques eBook
      http://doc.qt.io/qt-5/qmlfirststeps.html <- First Step in QML Documentation

      @Computer Science Student - Brazil
      Web Developer and Researcher
      “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

      1 Reply Last reply
      0
      • S Offline
        S Offline
        signalK
        wrote on last edited by signalK
        #3

        Ok !
        after creating a new project "try":
        file> new file or project> projects: Application> Qt quick application-Empty> choose build sydtem: qmake> etc ...> close
        I, in the editor, clicked on essai.pro to show the source code that I totally delete and replace it with basic like this:

        import QtQuick 2.3

        Rectangle {
        width: 200
        height: 100
        color: "red"

        Text {
            anchors.centerIn: parent
            text: "Hello, World!"
        }
        

        }
        it has compiled and executed well but by changing some values, nothing has changed!
        Why?

        thanks

        KillerSmathK 1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          which values you changed ? Did the program work when u created the "try" application ? Did it show window ?

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • S signalK

            Ok !
            after creating a new project "try":
            file> new file or project> projects: Application> Qt quick application-Empty> choose build sydtem: qmake> etc ...> close
            I, in the editor, clicked on essai.pro to show the source code that I totally delete and replace it with basic like this:

            import QtQuick 2.3

            Rectangle {
            width: 200
            height: 100
            color: "red"

            Text {
                anchors.centerIn: parent
                text: "Hello, World!"
            }
            

            }
            it has compiled and executed well but by changing some values, nothing has changed!
            Why?

            thanks

            KillerSmathK Offline
            KillerSmathK Offline
            KillerSmath
            wrote on last edited by KillerSmath
            #5

            @signalK

            after creating a new project "try":
            file> new file or project> projects: Application> Qt quick application-Empty> choose build sydtem: qmake> etc ...> close
            I, in the editor, clicked on essai.pro to show the source code that I totally delete and replace it with basic like this:

            .pro files will say how you project must be built. -> Read more: http://doc.qt.io/qt-5/qmake-project-files.html

            myproject.pro file

            TEMPLATE = app # what type of project is it.
            
            QT += qml quick # what modules are necessary in this project
            
            SOURCES += main.cpp # what sources files are necessary to compile
            
            RESOURCES += qml.qrc # "index file"
            
            # Default rules for deployment.
            qnx: target.path = /tmp/$${TARGET}/bin
            else: unix:!android: target.path = /opt/$${TARGET}/bin
            !isEmpty(target.path): INSTALLS += target
            

            If you want to customize your window, you should to change the main.qml because this file is loaded by QmlEngine (in main.cpp or main.py) to create a window.

            Example of a customized main.qml file

            import QtQuick 2.3
            import QtQuick.Window 2.3
            
            Window {
                visible: true
                width: 600
                height: 450
                minimumWidth: 210
                minimumHeight: 110
                title: "My First Application"
                // change color of background
                color: "steelblue"
            
                Rectangle{
                    width: 200
                    height: 100
                    // change color of rectangle
                    color: "darkslateblue"
                    // anchors in center of father (window)
                    anchors.centerIn: parent
                    // border settings
                    border.color: "black"
                    border.width: 2
            
                    Text{
                        text: "Hello World!"
                        // anchors in center of father (rectangle)
                        anchors.centerIn: parent
                        // Font Settings
                        color: "white"
                        font.family: "Arial"
                        font.pixelSize: 11
                    }
                }
            }
            

            > Where is the main.qml file ?

            0_1528865501039_qt_project.png

            @Computer Science Student - Brazil
            Web Developer and Researcher
            “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

            1 Reply Last reply
            0
            • S Offline
              S Offline
              signalK
              wrote on last edited by
              #6

              sorry
              my problem is solved

              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