ich bekomme das Layout nicht hin

Alles rund um die Programmierung mit Qt Quick und QML
Antworten
dl8aax
Beiträge: 10
Registriert: 2. Januar 2017 16:59
Wohnort: Bei Göttingen
Kontaktdaten:

ich bekomme das Layout nicht hin

Beitrag von dl8aax »

Moin,

ich versuche eine App fürs Handy zu machen.
Buttons in einer Reihe
darunter Editor zum scrollen
dann wieder Button

Hier mein Code

Code: Alles auswählen

import QtQuick 2.7
import Lomiri.Components 1.3
import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.3
import Qt.labs.settings 1.0
import QtQuick.Controls 2.2
import Qt.labs.platform 1.1
import QtQuick.LocalStorage 2.0

Page {
    id: notePage
    //title: i18n.tr("📝 Notizbuch")
    property var pageStackRef: null
    property var drawerRef: null
    property var settingsRef
    property bool selectionMode: false
    property int selectionAnchor: -1   // Startposition der Markierung
    
    QtObject {
        id: ubuntucolors
        property color orange: "#E95420"
        property color lightGreen: "#68B723"
        property color suruGrey: "#AEA79F"
        property color darkGrey: "#333333"
        property color slate: "#411934"
        property color lightGrey:"#DAE1E4"
        property color middlGrey:"#EACCFC"
    }
    header: PageHeader { 
        title: i18n.tr("Notizen")
        trailingActionBar.actions: [
            Action {
                iconName: "navigation-menu"
                text: "Menü"
                onTriggered: drawerRef.open()
            }
        ]
    }

    // === Layout-Struktur ===
     ColumnLayout {
         Rectangle{
             id:butbox
             color:ubuntucolors.lightGrey
             anchors.topMargin: units.gu(2)
         RowLayout {
            Layout.fillWidth: true
             
            spacing: units.gu(1)
            Button { id:b1; text: "B"; Layout.preferredWidth: units.gu(4.5); onClicked: insertTag("<b>", "</b>") }
            Button { text: "U"; Layout.preferredWidth: units.gu(4.5); onClicked: insertTag("<u>", "</u>") }
            Button { text: "I"; Layout.preferredWidth: units.gu(4.5); onClicked: insertTag("<i>", "</i>") }
            Button { text: "🔵"; Layout.preferredWidth: units.gu(4.5); onClicked: insertTag("<font color='blue'>", "</font>") }
            Button { text: "🔴"; Layout.preferredWidth: units.gu(4.5); onClicked: insertTag("<font color='red'>", "</font>") }
            Button { text: "💾"; Layout.preferredWidth: units.gu(4.5); onClicked: saveNote() }
        } // ende RowLayout
      }  
        
             
         ScrollView {
            y:b1.x + b1.height
     
    Layout.minimumHeight : 250
          
        TextEdit {
                id: editor
                
                //anchors.fill: parent 
                focus: true
                cursorVisible: true
                color: "black"
                selectionColor: "#7AA2E3" // Ein helles, sichtbares Blau
                selectedTextColor: "#FFFFFF" // Weißer Text auf blauem Hintergrund
                    
                font.pointSize: units.gu(1.5)
                text: "test"
                wrapMode: TextEdit.Wrap
                textFormat: TextEdit.RichText
                //anchors.fill: parent 
                height:units.gu(50)
        } 
             
        }
        
        
        RowLayout {
            Layout.fillWidth: true
             
            spacing: units.gu(1)
            Button { text: "◀"; Layout.preferredWidth: units.gu(4);   onClicked: moveCursor(-1) }
            Button { text: "▶"; Layout.preferredWidth: units.gu(4); onClicked: moveCursor(1)  }
            Button { text: "▲"; Layout.preferredWidth: units.gu(4);   onClicked: moveCursorLine(-1)}
            Button { text: "▼"; Layout.preferredWidth: units.gu(4);   onClicked: moveCursorLine(1) }
            // In NotizbuchPage.qml (im RowLayout der Formatierungs-Buttons)
            
            // Markiermodus aktivieren
            Button { 
                text: notePage.selectionMode ? "✅ Markieren" : "🔛 Markieren"
                Layout.preferredWidth: units.gu(10)
                background: Rectangle {
                    color: notePage.selectionMode ? ubuntucolors.orange : ubuntucolors.lightGrey
                    radius: 4
                }
                onClicked: {
                    notePage.selectionMode = !notePage.selectionMode
                    if (notePage.selectionMode) {
                    notePage.selectionAnchor = editor.cursorPosition
                    } else {
                    editor.select(editor.cursorPosition, editor.cursorPosition)
                    notePage.selectionAnchor = -1
                    }
                    focusTimer.start()
                }
            }

            // 🚫 Markierung aufheben
            Button {
                text: "🚫"
                Layout.preferredWidth: units.gu(4)
                onClicked: {
                    notePage.selectionMode = false
                    notePage.selectionAnchor = -1
                    editor.select(editor.cursorPosition, editor.cursorPosition)
                    focusTimer.start()
                }
            }
            Button { text: "h"; Layout.preferredWidth: units.gu(4); onClicked: insertTag("<i>", "</i>") }
            Button { text: "r"; Layout.preferredWidth: units.gu(4); onClicked: insertTag("<font color='blue'>", "</font>") }
        } //Ende RowLayout
         
        Component.onCompleted: {
            editor.focus=true
            
        }
    } // ende ColumnLayout
    
die oberen Button sind im Editor und die unteren Button schieben nach unten aus den Bildschirm wenn die Zeilenzahl höher wird.

Lg Dirk
editorkaputt1.png
editorkaputt1.png (18.85 KiB) 2819 mal betrachtet
Antworten