maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   Help me to code for Sailfish OS (https://talk.maemo.org/showthread.php?t=100817)

Markkyboy 2020-09-08 11:26

Arranging numbers/letters/tickmarks in a circle
 
1 Attachment(s)
My application shows a dial with compass bearings (numbers) and tickmarks (asterisks).

I cannot use QML CircularGauge for my purpose because 'Controls.Styles' is not available in SFOS.

Currently, I am using this method for placing my text/numbers in a circular fashion;

Code:

    Rectangle {
            color: "#00000000"; width: 520; height: 520; radius: 260; anchors.centerIn: parent
            Repeater {
                id: tickmarks
                model: {
                    [
                    ' ', '*', '*', ' ', '*', '*', ' ', '*', '*', ' ', '*', '*',
                    ' ', '*', '*', ' ', '*', '*', ' ', '*', '*', ' ', '*', '*',
                    ' ', '*', '*', ' ', '*', '*', ' ', '*', '*', ' ', '*', '*'
                    ]
                }
                delegate: Rectangle {
                    height: 260
                    anchors.horizontalCenter: parent.horizontalCenter
                    transformOrigin: Rectangle.Bottom
                    rotation: 360 / tickmarks.model.length * index
                    Text {
                        text: modelData
                        color: Theme.secondaryHighlightColor
                        font {
                            bold: Font.Bold
                            pixelSize: 28
                        }
                        anchors.horizontalCenter: parent.horizontalCenter
                    }
                }
            }
        }

The above code is messy and clunky, among other things. How can I refine this code or is there a better way to achieve what is shown in the image?

thanks,

coderus 2020-09-08 11:32

Re: Help me to code for Sailfish OS
 
found this https://github.com/RSATom/Qt/blob/ma...GaugeStyle.qml
i think its easy to copy and implement as standalone item

Markkyboy 2020-09-08 12:42

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1569166)
found this https://github.com/RSATom/Qt/blob/ma...GaugeStyle.qml
i think its easy to copy and implement as standalone item

But that shows Controls.Styles as an import statement. I had already tried stripping down CircularGauge QML, but Controls.Styles is required.

/* I'll play anyway, its a huge file for what it does, amazing.*/
EDIT, I decided against playing with this file, it requires 4 import modules that are not available in SFOS.

thanks,

coderus 2020-09-08 14:29

Re: Help me to code for Sailfish OS
 
Grab minimal code, then go to styles if you really need it. For bare minimal code inside CircularGaugeStyle is enough to be copied to standalone item

Markkyboy 2020-09-08 16:33

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1569170)
Grab minimal code, then go to styles if you really need it. For bare minimal code inside CircularGaugeStyle is enough to be copied to standalone item

Okay, but I'm sure 'Styles' is also not available in SFOS. I have tried many import statements that are not available. I've looked through '/usr/lib/qt5/qml' on my device and didn't see 'controls' or 'styles'......?

coderus 2020-09-08 17:25

Re: Help me to code for Sailfish OS
 
you can't just copy and paste, you have to code the code! you can take idea from existing qtquick item and adapt to your project.

Maemish 2020-09-08 17:28

Re: Help me to code for Sailfish OS
 
Is this anyway related even though there is no ready answer?

https://talk.maemo.org/showthread.php?t=96839

coderus 2020-09-08 17:34

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by Maemish (Post 1569175)
Is this anyway related even though there is no ready answer?

https://talk.maemo.org/showthread.php?t=96839

dont miss %install step to actually copy files-to-be-packaged to %{buildroot}, then %files section can package it. files outside %{buildroot} can't be packaged.

Maemish 2020-09-08 19:22

Re: Help me to code for Sailfish OS
 
Would rinigus know answer to this? It seems he has done some stuff which may include something related.

rob_kouw 2020-09-09 20:27

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1568965)
i dont know a way to do this in pure qml without c++ code

So, the question was:
- There is a page with a ListView, with a model from database contents
- Tapping on an item opens a new Dialog, where the database item could change
- popping the dialog leaves an old listview that needs refreshing

Now, I found your GitHub page on callbacks: https://gist.github.com/CODeRUS/5235...bfaf0bafbeb7cd

Could I push the dialog with a callback to a function that would update the listview? Or is that not what the callback is for? Something like:
pageStack.push(Qt.resolvedUrl("DialogPage.qml"), {callback: updateListViewAfterDialog })

Update: yes, this seems to work!


All times are GMT. The time now is 16:32.

vBulletin® Version 3.8.8