This forum has been archived. All content is frozen. Please use KDE Discuss instead.

simple clock plasmoid, how?

Tags: None
(comma "," separated)
ChemBro
Registered Member
Posts
69
Karma
0
OS

simple clock plasmoid, how?

Sat Feb 07, 2015 11:29 pm
I'm trying to write a simple clock plasmoid, but... Dunno. Doesn't work for me. I either have no text at all or the clock does not update itself.

Some example code:

Code: Select all
    Text {
        id: maintime
        font.family: theme.desktopFont  //can't be right, though I don't know what should be right.
        color: theme.textColor
        font.bold: true
        font.pointSize: 72
        text: Qt.formatDateTime(new Date(), "hh:mm:ss"); //displays the time, but it does not get updated
        //text.: Qt.formatDateTime( dataSource.data.Local.Time, "hh:mm:ss" ); //dunno about this, thought this is the "new method", no text is displayed
        //text: Qt.formatDateTime( dataSource.data["Local"]["Time"],"hh:mm:ss" ); //this should have worked in KDE4, nothing displayed
    }

    PlasmaCore.DataSource {
        id: dataSource
        engine: "time"
        connectedSources: ["Local"]
        interval: 500
    }


This "new Date()" thing works, though the clock stops, doesn't move on. The other 2 examples just don't show any text. I don't know why. I don't know, if there is a nice IDE for plasmoids. Also the documentation is... dunno. Not enough for me, it seems.

What am I missing here? Why is the text not displayed and/or updated?
User avatar
google01103
Manager
Posts
6668
Karma
25

Re: simple clock plasmoid, how?

Sat Feb 07, 2015 11:39 pm
moved to KDE Development -> Helping Hands


OpenSuse Leap 42.1 x64, Plasma 5.x

User avatar
Rog131
Registered Member
Posts
828
Karma
10

Re: simple clock plasmoid, how?  Topic is solved

Mon Mar 02, 2015 10:09 am
Plasma 5 clock examples

Reusing the sddm clock: https://www.kubuntuforums.net/showthrea ... post367789

Reusing the Qt Quick Demo Clocks: https://www.kubuntuforums.net/showthrea ... post367872
ChemBro
Registered Member
Posts
69
Karma
0
OS

Re: simple clock plasmoid, how?

Mon Mar 02, 2015 10:47 am
Thank you. Basically I needed this lines of code:

Code: Select all
    property date dateTime: new Date();
   
    Timer {
            interval: 100; running: true; repeat: true;
            onTriggered: container.dateTime = new Date();
    }

    text: Qt.formatTime(container.dateTime, "hh:mm:ss");


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Google [Bot], Sogou [Bot]