Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

insert basic code source and run it



  • 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



  • @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



  • 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


  • Qt Champions 2017

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



  • @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



  • sorry
    my problem is solved


Log in to reply