Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. User Customizable Touch Screen Interface.
Forum Updated to NodeBB v4.3 + New Features

User Customizable Touch Screen Interface.

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
15 Posts 3 Posters 3.9k Views 2 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #6

    Then it really looks like you should provide an editor that generates the configuration files the way your application expects them rather than rely only user input without any validation.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cdw3423
      wrote on last edited by
      #7

      Maybe, but that has nothing to do with Qt or how I should design the app. I'm asking for input on how to use Qt. The way my config files are maintained is not relevant. What I need help with is how to get started with the GUI in Qt.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #8

        Well, partly it does, because you could be generating QtQuick controls out of your configuration for your application to load for example. Thus it could be mainly a "loader" that handles these "pages".

        Otherwise you'd need a parser to generate dynamically the interface.

        In any case, you should take a look at QtQuick and the Graphics View framework to see which one might fit better your need.

        I'd rather not start with custom static images. You would have to know the place of each and every button, check for every touch whether it's in the geometry of any button and the user wouldn't have any visual feed back that there's something happening when he presses one of theses buttons.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cdw3423
          wrote on last edited by
          #9

          I took a look at QtQuick and created a simple qml app with code listed below and the image I used to represent all 20 buttons.

          So I have a few questions.
          How can I load the qml file at run time and also the image file. The only way I could get the image to show up at run time was to manually edit the qml.qrc file and add <file>Buttons.png</file>. Before I did that, the image would show up in the QtCreator design view but would not show up when I ran the app. As you can see, there is user feedback when the mouse is pressed. I'm assuming I can use similar code for touch events. Also I need to figure out how to have a swipe action switch between images.
          Right now I am doing this all on a windows PC, it sounds like the best way to build this for the Raspberry pi is to install linux on a PC and build it with Qt on linux.

          MainForm.ui.qml

          import QtQuick 2.6
          
          Rectangle {
              property alias mouseArea: mouseArea
              width: 500
              height: 400
              property alias repeater: repeater
          
              Image {
                  id: image
                  anchors.fill: parent
                  source: "Buttons.png"
              }
          
              MouseArea {
                  id: mouseArea
                  anchors.fill: parent
                  Grid {
                      id: grid
                      rows: 4
                      columns: 5
                      anchors.fill: parent
                      Repeater {
                          id:repeater
                          model: 20
                          Rectangle{
                              width: 100
                              height: 100
                              color: "#868686"
                              radius: 5
                              opacity: 0
                              border.width: 2
                          }
                      }
                  }
              }
          }
          

          and Main.qml

          import QtQuick 2.6
          import QtQuick.Window 2.2
          
          Window {
              visible: true
              width: 500
              height: 400
              title: qsTr("Hello World")
              property int rectIdx
          
              MainForm {
                  anchors.fill: parent
                  mouseArea.onClicked: {
                      //console.log(qsTr('Clicked on background. Text: "' + textEdit.text + '"'))
                  }
                  mouseArea.onPressed: {
                      rectIdx = getRectIdx(mouseArea.mouseX, mouseArea.mouseY)
                      //console.log(qsTr('Rect Coord "' + xCord + ', ' + yCord + '" idx: ' + rectIdx))
                      repeater.itemAt(rectIdx).opacity = .8
                  }
                  mouseArea.onReleased: {
                      rectIdx = getRectIdx(mouseArea.mouseX, mouseArea.mouseY)
                      //console.log(qsTr('Rect Coord "' + xCord + ', ' + yCord + '" idx: ' + rectIdx))
                      repeater.itemAt(rectIdx).opacity = 0
                  }
              }
              function getRectIdx(x, y){
                  x = x/100;
                  y = y/100;
                  y = y|0;
                  x = x|0;
                  return y * 5 + x;
              }
          }
          
          

          alt text

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #10

            qrc files are read-only and end up as a .cpp file that is compiled.

            Your images are not found likely because you're using a relative path.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            C 1 Reply Last reply
            0
            • SGaistS SGaist

              qrc files are read-only and end up as a .cpp file that is compiled.

              Your images are not found likely because you're using a relative path.

              C Offline
              C Offline
              cdw3423
              wrote on last edited by
              #11

              @SGaist
              I figured out the relative path problem. But I can't find anyway to get an image added as built in resource using Qt Creator 4.2.1 with out manually editing qml.qrc. I have to reload the project after that edit I think. If there is some way to add items to the resources using the Qt Creator UI, I can't find it.

              jsulmJ 1 Reply Last reply
              0
              • C cdw3423

                @SGaist
                I figured out the relative path problem. But I can't find anyway to get an image added as built in resource using Qt Creator 4.2.1 with out manually editing qml.qrc. I have to reload the project after that edit I think. If there is some way to add items to the resources using the Qt Creator UI, I can't find it.

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

                @cdw3423

                1. Select resource file in QtCreator
                2. Right click on it then "Open With/Resource Editor"
                3. Add/remove files there

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

                C 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @cdw3423

                  1. Select resource file in QtCreator
                  2. Right click on it then "Open With/Resource Editor"
                  3. Add/remove files there
                  C Offline
                  C Offline
                  cdw3423
                  wrote on last edited by
                  #13

                  @jsulm Last night when I read your post, I was sure I had tried to right click and nothing happened. But I tried it and it did work. Today I decided to do some more experimenting and once again right clicking on the resource file doesn't do anything. So I opened a few different projects and still no joy. I'm not sure if this is a bug or if somehow I am in a mode that won't let me see the right click options. I tried it with and with out a project running.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #14

                    What happens if you just select the .qrc file ? You should get a nice editor.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    C 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      What happens if you just select the .qrc file ? You should get a nice editor.

                      C Offline
                      C Offline
                      cdw3423
                      wrote on last edited by
                      #15

                      @SGaist
                      Last night when I tried, it was all working, but not today. Maybe I will install it on a different computer and see what happens.

                      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