Skip to content

Instantly share code, notes, and snippets.

@dtoebe
Created January 3, 2017 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtoebe/13de4b8483dbf4f04fcb177c247e65d4 to your computer and use it in GitHub Desktop.
Save dtoebe/13de4b8483dbf4f04fcb177c247e65d4 to your computer and use it in GitHub Desktop.
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.qml - 3
//assets/main.qml
import QtQuick 2.3
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.0
import TextConverter 1.0 //The import name is the string from the first param in the qml.RegisterTypes then the number 1 is from the next param, then dot third param
ApplicationWindow {
...
color: "#f1f1f1" // Old code for point of reference
HTMLText { //Note the entity is the same name as the struct we created
id: htmlText //Unique identifier
text: "" //We create this to initialize the text param
//Also note the lowercase text param I will explain below
}
...
TextArea {
id: mdarea
...
Keys.onReleased: { //While the mdarea is in focus and once you release after a key press we will call this function
htmlText.setHTMLText(mdarea.text) //Here we run the method called in our Go code that will set the HTMLText.Text
rtarea.text = htmlText.text //Here we call the htmlText by its Id and set rtarea's text param as the formatted text
}
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment