maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   QML and SelectionDialog [and other QML-related questions] (https://talk.maemo.org/showthread.php?t=85113)

marmistrz 2012-06-26 14:47

QML and SelectionDialog [and other QML-related questions]
 
1 Attachment(s)
Hi
I'm learning QML.
My code is:
Code:

import QtQuick 1.0
import org.maemo.fremantle 1.0

Column
{
    property color fontcolor: "white"
    Row
    {
        width: parent.width
        CheckBox
        {
            id: tracksrc
            //text: "Select track from library"
            checked: true
            //checkable: true
        }
        Label
        {
            id: tracksrcText
            text: "Select track from library"
            anchors.verticalCenter: tracksrc.verticalCenter
            color: fontcolor
        }
    }

    Label
    {
        id: selecttracklabel
        text: "Selected track"
        color: fontcolor
    }
    Button
    {
        id: selecttrack
        text: "No track selected"
        checkable: false
        width: parent.width
    }

    SelectionDialog
    {
        id: lyricssrcdialog
        titleText: "Download source"
        selectedIndex: 1
        model: ListModel
        {
            ListElement { name: "AZLyrics" }
        }
    }
    Button
    {
        id: lyricssrcbutton
        text: lyricssrcdialog.model.get(lyricssrcdialog.selectedIndex).name
        width: parent.width
        onClicked: { lyricssrcdialog.open(); }
    }

    Button
    {
        id: go
        text: "Go!"
        width: parent.width
    }
}

I'm attaching the log.
I want the lyricssrcbutton to display the currently selected option.
Why isn't it working. What's the problem with the loops?
Thanks in advance.

Slocan 2012-06-26 16:11

Re: QML and SelectionDialog
 
The SelectionDialog is in its own Popup window, you can't place it inside a Column/Row, so it's giving you those loop warnings (column and dialog battling out to see who will provide the layout).

dicksonleong8 2012-06-26 16:18

Re: QML and SelectionDialog
 
@Slocan are right

1 more thing is your SelectionDialog's selectedIndex should be start with 0, not 1

marmistrz 2012-06-27 15:28

Re: QML and SelectionDialog
 
I'm still having problems. The index set for 0 solves one the problem of a blank label, but
With this code:
Code:

import QtQuick 1.0
import org.maemo.fremantle 1.0
Rectangle
{
    property color fontcolor: "white"
    Column
    {
        id: c1
        Row
        {
            width: parent.width
            CheckBox
            {
                id: tracksrc
                //text: "Select track from library"
                checked: true
                //checkable: true
            }
            Label
            {
                id: tracksrcText
                text: "Select track from library"
                anchors.verticalCenter: tracksrc.verticalCenter
                color: fontcolor
            }
        }

        Label
        {
            id: selecttracklabel
            text: "Selected track"
            color: fontcolor
        }
        Button
        {
            id: selecttrack
            text: "No track selected"
            checkable: false
            width: parent.width
        }
    }
    Rectangle
    {
        id: r1
        anchors.top: c1.bottom
        SelectionDialog
        {
            id: lyricssrcdialog
            titleText: "Download source"
            selectedIndex: 0
            model: ListModel
            {
                ListElement { name: "AZLyrics" }
            }
        }
        Button
        {
            id: lyricssrcbutton
            text: lyricssrcdialog.model.get(lyricssrcdialog.selectedIndex).name
            width: parent.width
            onClicked: { lyricssrcdialog.open(); }
        }
    }
    Column
    {
        id: c2
        anchors.top: r1.bottom
        Button
        {
            id: go
            text: "Go!"
            width: parent.width
        }
    }
}

There's only black, blank screen showing up. If only the selectedIndex property is changed:
Code:

import QtQuick 1.0
import org.maemo.fremantle 1.0

Column
{
    property color fontcolor: "white"
    Row
    {
        width: parent.width
        CheckBox
        {
            id: tracksrc
            //text: "Select track from library"
            checked: true
            //checkable: true
        }
        Label
        {
            id: tracksrcText
            text: "Select track from library"
            anchors.verticalCenter: tracksrc.verticalCenter
            color: fontcolor
        }
    }

    Label
    {
        id: selecttracklabel
        text: "Selected track"
        color: fontcolor
    }
    Button
    {
        id: selecttrack
        text: "No track selected"
        checkable: false
        width: parent.width
    }

    SelectionDialog
    {
        id: lyricssrcdialog
        titleText: "Download source"
        selectedIndex: 0
        model: ListModel
        {
            ListElement { name: "AZLyrics" }
        }
    }
    Button
    {
        id: lyricssrcbutton
        text: lyricssrcdialog.model.get(lyricssrcdialog.selectedIndex).name
        width: parent.width
        onClicked: { lyricssrcdialog.open(); }
    }

    Button
    {
        id: go
        text: "Go!"
        width: parent.width
    }
}

then it's showing up alright, but throwing that load of loops detected as before. Where should I move the selection dialog?

ajalkane 2012-06-27 15:41

Re: QML and SelectionDialog
 
Quote:

Originally Posted by marmistrz (Post 1228242)
then it's showing up alright, but throwing that load of loops detected as before. Where should I move the selection dialog?

Perhaps like this (notice I wrapped Column inside Item):
Code:

Item {

Column
{
    property color fontcolor: "white"
    Row
    {
        width: parent.width
        CheckBox
        {
            id: tracksrc
            //text: "Select track from library"
            checked: true
            //checkable: true
        }
        Label
        {
            id: tracksrcText
            text: "Select track from library"
            anchors.verticalCenter: tracksrc.verticalCenter
            color: fontcolor
        }
    }

    Label
    {
        id: selecttracklabel
        text: "Selected track"
        color: fontcolor
    }
    Button
    {
        id: selecttrack
        text: "No track selected"
        checkable: false
        width: parent.width
    }

    Button
    {
        id: lyricssrcbutton
        text: lyricssrcdialog.model.get(lyricssrcdialog.selectedIndex).name
        width: parent.width
        onClicked: { lyricssrcdialog.open(); }
    }

    Button
    {
        id: go
        text: "Go!"
        width: parent.width
    }
}


    SelectionDialog
    {
        id: lyricssrcdialog
        titleText: "Download source"
        selectedIndex: 0
        model: ListModel
        {
            ListElement { name: "AZLyrics" }
        }
    }
}


marmistrz 2012-06-29 15:33

Re: QML and SelectionDialog
 
Quote:

Originally Posted by ajalkane (Post 1228245)
Perhaps like this (notice I wrapped Column inside Item):
Code:

Item {

Column
{
    property color fontcolor: "white"
    Row
    {
        width: parent.width
        CheckBox
        {
            id: tracksrc
            //text: "Select track from library"
            checked: true
            //checkable: true
        }
        Label
        {
            id: tracksrcText
            text: "Select track from library"
            anchors.verticalCenter: tracksrc.verticalCenter
            color: fontcolor
        }
    }

    Label
    {
        id: selecttracklabel
        text: "Selected track"
        color: fontcolor
    }
    Button
    {
        id: selecttrack
        text: "No track selected"
        checkable: false
        width: parent.width
    }

    Button
    {
        id: lyricssrcbutton
        text: lyricssrcdialog.model.get(lyricssrcdialog.selectedIndex).name
        width: parent.width
        onClicked: { lyricssrcdialog.open(); }
    }

    Button
    {
        id: go
        text: "Go!"
        width: parent.width
    }
}


    SelectionDialog
    {
        id: lyricssrcdialog
        titleText: "Download source"
        selectedIndex: 0
        model: ListModel
        {
            ListElement { name: "AZLyrics" }
        }
    }
}


With this code:
Code:

import QtQuick 1.0
import org.maemo.fremantle 1.0
Item
{
    Loader
    {
        id: goloader
        onLoaded: console.log("Go! clicked")
    }
    Loader
    {
        id: selecttrackloader
        onLoaded: console.log("Select track view loaded")
    }

    Column
    {
        property color fontcolor: "white"
        Row
        {
            width: parent.width
            CheckBox
            {
                id: tracksrc
                //text: "Select track from library"
                checked: true
                //checkable: true
            }
            Label
            {
                id: tracksrcText
                text: "Select track from library"
                anchors.verticalCenter: tracksrc.verticalCenter
                color: fontcolor
            }
        }

        Label
        {
            id: selecttracklabel
            text: "Selected track"
            color: fontcolor
        }
        Button
        {
            id: selecttrack
            text: "No track selected"
            checkable: false
            width: parent.width
            onClicked:
            {
            }
        }

        Button
        {
            id: lyricssrcbutton
            text: lyricssrcdialog.model.get(lyricssrcdialog.selectedIndex).name
            width: parent.width
            onClicked: { lyricssrcdialog.open(); }
        }

        Button
        {
            id: go
            text: "Go!"
            width: parent.width
        }
    }


    SelectionDialog
    {
        id: lyricssrcdialog
        titleText: "Download source"
        selectedIndex: 0
        model: ListModel
        {
            ListElement { name: "AZLyrics" }
        }
    }

}

I'm getting
Code:

.../main.qml:53 ReferenceError: Can't find variable fontcolor
.../main.qml:45 ReferenceError: Can't find variable fontcolor

What am I doing wrong?

ajalkane 2012-07-03 06:55

Re: QML and SelectionDialog
 
Quote:

Originally Posted by marmistrz (Post 1229083)
With this code:
[CODE]
I'm getting
Code:

.../main.qml:53 ReferenceError: Can't find variable fontcolor
.../main.qml:45 ReferenceError: Can't find variable fontcolor

What am I doing wrong?

I think you can't have property declarations anywhere else than the root item. So try to move 'property color fontcolor: "white"' under Item.

marmistrz 2012-07-03 11:25

Re: QML and SelectionDialog
 
Quote:

Originally Posted by ajalkane (Post 1230491)
I think you can't have property declarations anywhere else than the root item. So try to move 'property color fontcolor: "white"' under Item.

That way there are no errors, but still somehow only blank screen is painted..

ajalkane 2012-07-03 11:53

Re: QML and SelectionDialog
 
Quote:

Originally Posted by marmistrz (Post 1230665)
That way there are no errors, but still somehow only blank screen is painted..

That's another problem then. In those kind of situations, I've found it useful to put up a minimal working page (say one component). Then start adding stuff until you've isolated the problem.

marmistrz 2012-07-03 12:08

Re: QML and SelectionDialog
 
Quote:

Originally Posted by ajalkane (Post 1230705)
That's another problem then. In those kind of situations, I've found it useful to put up a minimal working page (say one component). Then start adding stuff until you've isolated the problem.

Wait... Does Item require x,y coordinates? It may be why it's a blank screen. As putting any component in a Rectangle caused not showing up of this component.

ajalkane 2012-07-03 12:18

Re: QML and SelectionDialog
 
Quote:

Originally Posted by marmistrz (Post 1230727)
Wait... Does Item require x,y coordinates? It may be why it's a blank screen. As putting any component in a Rectangle caused not showing up of this component.

It does not require x/y co-ordinates, but of course it has basically no width/height if you don't specify them. It can be a problem if its descendants use indirectly the Item's width/height to calculate their size.

marmistrz 2012-07-03 18:15

Re: QML and SelectionDialog
 
Quote:

Originally Posted by ajalkane (Post 1230740)
It does not require x/y co-ordinates, but of course it has basically no width/height if you don't specify them. It can be a problem if its descendants use indirectly the Item's width/height to calculate their size.

Is there any way I can tell the Rectangle to occupy the maximum size (as it's with Column only), so that in landscape N900 it'll be 800x480, portrait N900 480x800, portrait N9 480x854 and so on?

ajalkane 2012-07-03 18:36

Re: QML and SelectionDialog
 
Quote:

Originally Posted by marmistrz (Post 1231147)
Is there any way I can tell the Rectangle to occupy the maximum size (as it's with Column only), so that in landscape N900 it'll be 800x480, portrait N900 480x800, portrait N9 480x854 and so on?

I don't know about N900, but for N9 see the QML Window component's sources on how to do it. Here's its documentation:

http://harmattan-dev.nokia.com/docs/...go-window.html

marmistrz 2012-07-03 19:23

Re: QML and SelectionDialog
 
Quote:

Originally Posted by ajalkane (Post 1231168)
I don't know about N900, but for N9 see the QML Window component's sources on how to do it. Here's its documentation:

http://harmattan-dev.nokia.com/docs/...go-window.html

I think it's what I'm looking for, as I plan to release my programs not only for N900 but for N9 too.

But somehow the hildon status menu is still shown. changing showExpanded() to showMaximized() doesn't work.

thanks in advance.

Here's my main.qml
Code:

import QtQuick 1.0
import org.maemo.fremantle 1.0

//property color fontcolor: "white"

PageStackWindow
{
    property color fontcolor: "white"
    initialPage: Component
    {
        Column
        {
            Row
            {
                width: parent.width
                CheckBox
                {
                    id: tracksrc
                    //text: "Select track from library"
                    checked: true
                    //checkable: true
                }
                Label
                {
                    id: tracksrcText
                    text: "Select track from library"
                    anchors.verticalCenter: tracksrc.verticalCenter
                    color: fontcolor
                }
            }

            Label
            {
                id: selecttracklabel
                text: "Selected track"
                color: fontcolor
            }
            Button
            {
                id: selecttrack
                text: "No track selected"
                checkable: false
                width: parent.width
                onClicked:
                {

                }
            }

            SelectionDialog
            {
                id: lyricssrcdialog
                titleText: "Download source"
                selectedIndex: 0
                model: ListModel
                {
                    ListElement { name: "AZLyrics" }
                }
            }
            Button
            {
                id: lyricssrcbutton
                text: lyricssrcdialog.model.get(lyricssrcdialog.selectedIndex).name
                width: parent.width
                onClicked: { lyricssrcdialog.open(); }
            }

            Button
            {
                id: go
                text: "Go!"
                width: parent.width
            }
        }
    }
}


ajalkane 2012-07-03 20:32

Re: QML and SelectionDialog
 
Quote:

Originally Posted by marmistrz (Post 1231211)
I think it's what I'm looking for, as I plan to release my programs not only for N900 but for N9 too.

But somehow the hildon status menu is still shown. changing showExpanded() to showMaximized() doesn't work.

I'm not familiar with Fremantle, but on Harmattan PageStackWindow's showStatusBar property should do the trick:

Code:

PageStackWindow
{
    showStatusBar: false
    ...
}

In C++ showFullScreen() should be called.

marmistrz 2012-07-04 08:55

Re: QML and SelectionDialog
 
Quote:

Originally Posted by ajalkane (Post 1231278)
I'm not familiar with Fremantle, but on Harmattan PageStackWindow's showStatusBar property should do the trick:

Code:

PageStackWindow
{
    showStatusBar: false
    ...
}

In C++ showFullScreen() should be called.

OK. I'm starting to work it out. showStatusBar should be true, and only showFullScreen() in C++.
Is there any way I set the width of the buttons to be resized as the screen rotates? With Column only I set
Code:

width: parent.width
But with PageStackWindow the width is set well only after clicking the button pointing to the SelectionDialog. And
Code:

screen.width
is always 800 even after rotation (then it should be 480)

marmistrz 2012-07-04 13:48

Re: QML and SelectionDialog
 
Quote:

Originally Posted by marmistrz (Post 1231594)
OK. I'm starting to work it out. showStatusBar should be true, and only showFullScreen() in C++.
Is there any way I set the width of the buttons to be resized as the screen rotates? With Column only I set
Code:

width: parent.width
But with PageStackWindow the width is set well only after clicking the button pointing to the SelectionDialog. And
Code:

screen.width
is always 800 even after rotation (then it should be 480)


I finally worked it out with
Code:

    property int screenwidth: (screen.currentOrientation == Screen.Landscape) ? screen.displayWidth : screen.displayHeight
But I've got another problem. I want to divide the program into multiple files but
Files are:
main.qml - the main one, only PageStackWindow
mainView.qml - Page used by main.qml

And I'm getting
Code:

Can't find variable: mainView
I tried importing
Code:

import "."
import "mainView.qml"
import "mainView.qml" as mainView

But nothing works.
thanx in advance

nicolai 2012-07-04 13:59

Re: QML and SelectionDialog
 
No need to import your own qml-file
as long as it is in the same directory.
How does your main.qml file looks like?
The one with the pagestackwindow
must have set the initialPage property.

Here is a simple example
http://harmattan-dev.nokia.com/docs/...etutorial.html

ajalkane 2012-07-04 20:41

Re: QML and SelectionDialog
 
Quote:

Originally Posted by marmistrz (Post 1231767)
But I've got another problem. I want to divide the program into multiple files but
Files are:
main.qml - the main one, only PageStackWindow
mainView.qml - Page used by main.qml

And I'm getting
Code:

Can't find variable: mainView
I tried importing
Code:

import "."
import "mainView.qml"
import "mainView.qml" as mainView

But nothing works.
thanx in advance

You should rename it to MainView.qml. Remove the imports, they're automatically imported. But the naming is important, ie. capital start letter.

So after that you can use it in main.qml like:

Code:

PageStackWindow {
  ...
  MainView {
    ...
  }
}


marmistrz 2012-07-05 09:34

Re: QML and SelectionDialog
 
Quote:

Originally Posted by ajalkane (Post 1232024)
You should rename it to MainView.qml. Remove the imports, they're automatically imported. But the naming is important, ie. capital start letter.

So after that you can use it in main.qml like:

Code:

PageStackWindow {
  ...
  MainView {
    ...
  }
}


OK, thanks for help. Seems that I used it wrong (as if it was #include and extern declaration in C++), thinking it was already declared.

marmistrz 2012-07-08 11:15

Re: QML and SelectionDialog
 
Is there a prebuilt "OK" dialog in qml, like this: http://www.roseindia.net/java/exampl...eDialogBox.gif
?
Thanks in advance

EDIT: QueryDialog seems to work great.

marmistrz 2012-07-13 09:03

Re: QML and SelectionDialog
 
Hi,
I want the selecttrack Button to hide when a checkbox isn't checked. my code is:
Code:

import QtQuick 1.0
import org.maemo.fremantle 1.0

Page
{
    id: mainPage
    tools: toolbar
    Column
    {

        signal tracksrcChanged(bool state)
        width: parent.width
        CheckBox
        {
            id: tracksrc
            text: "Select track from library" // label isn't needed with PageStackWindow
            checked: true
            //checkable: true

            onClicked:
            {
              mainPage.tracksrcChanged(checked)
            }
        }

        Label
        {
            id: selecttracklabel
            text: "Selected track"
        }
        Button
        {
            id: selecttrack
            text: "No track selected"
            checkable: false
            width: screenwidth
            onClicked:
            {
                console.log("Select track button clicked")
                pageStack.push(Qt.resolvedUrl("SelectTrackPage.qml"))
            }
            onTracksrcChanged:
            {
                ( state == true ) ? this.show()  :this.hide()
            }
        }
        Button
        {
            id: lyricssrcbutton
            text: lyricssrcdialog.model.get(lyricssrcdialog.selectedIndex).name
            width: screenwidth
            onClicked: { lyricssrcdialog.open(); }
        }

        Button
        {
            id: go
            text: "Go!"
            width: screenwidth
            onClicked:
            {
              console.log("Go! button clicked")
              pageStack.push(Qt.resolvedUrl("ShowLyricsPage.qml"))
            }
        }
    }
    SelectionDialog
    {
        id: lyricssrcdialog
        titleText: "Download source"
        selectedIndex: 0
        model: ListModel
        {
            ListElement { name: "AZLyrics" }
        }
    }
    OKDialog
    {
        id: notimplementeddialog
        message: "Sorry, not implemented yet!"
    }
}

I'm getting error
Code:

.../MainPage.qml:42:13: Cannot assign to non-existent property onTracksrcChanged:
What am I doing wrong?

nicolai 2012-07-13 09:12

Re: QML and SelectionDialog [and other QML-related questions]
 
tracksrcChanged is a signal in Column
you can not access it within
Code:

Button {
id: selecttrack
onTracksrcChanged { ...
}

the onTracksrcChanged would work, only if trackSrcChanged is a property of
selecttrack

The easier solution would be:
Code:

Button
        {
            id: selecttrack
            text: "No track selected"
            checkable: false
            width: screenwidth
            visible:tracksrc.checked
            onClicked:
            {
                console.log("Select track button clicked")
                pageStack.push(Qt.resolvedUrl("SelectTrackPage.qml"))
            }
}


marmistrz 2012-07-13 09:45

Re: QML and SelectionDialog [and other QML-related questions]
 
Quote:

Originally Posted by nicolai (Post 1236935)
tracksrcChanged is a signal in Column
you can not access it within
Code:

Button {
id: selecttrack
onTracksrcChanged { ...
}

the onTracksrcChanged would work, only if trackSrcChanged is a property of
selecttrack

The easier solution would be:
Code:

Button
        {
            id: selecttrack
            text: "No track selected"
            checkable: false
            width: screenwidth
            visible:tracksrc.checked
            onClicked:
            {
                console.log("Select track button clicked")
                pageStack.push(Qt.resolvedUrl("SelectTrackPage.qml"))
            }
}


Thanks.
I've got one more question: is there something like vertical spacer in QML, so that I don't have to hardcore any pixel heights?

Slocan 2012-07-13 22:48

Re: QML and SelectionDialog [and other QML-related questions]
 
Quote:

Originally Posted by marmistrz (Post 1236948)
Thanks.
I've got one more question: is there something like vertical spacer in QML, so that I don't have to hardcore any pixel heights?

You can use Rectangles, or Items.

marmistrz 2012-07-14 12:13

Re: QML and SelectionDialog [and other QML-related questions]
 
Quote:

Originally Posted by Slocan (Post 1237220)
You can use Rectangles, or Items.

But then I'll have to specify the height. And I want the spacer to automatically detect the space to take


Quote:

Originally Posted by nicolai (Post 1236935)
tracksrcChanged is a signal in Column
you can not access it within
Code:

Button {
id: selecttrack
onTracksrcChanged { ...
}

the onTracksrcChanged would work, only if trackSrcChanged is a property of
selecttrack

The easier solution would be:
Code:

Button
        {
            id: selecttrack
            text: "No track selected"
            checkable: false
            width: screenwidth
            visible:tracksrc.checked
            onClicked:
            {
                console.log("Select track button clicked")
                pageStack.push(Qt.resolvedUrl("SelectTrackPage.qml"))
            }
}


Is it possible to specify an animation for this?

marmistrz 2012-07-17 08:48

Re: QML and SelectionDialog [and other QML-related questions]
 
Which component should I use to have look as used in the MeeGo Settings control panel?

How can I get the default height of a button?
thanks in advance

Slocan 2012-07-17 18:28

Re: QML and SelectionDialog [and other QML-related questions]
 
Quote:

Originally Posted by marmistrz (Post 1237397)
But then I'll have to specify the height. And I want the spacer to automatically detect the space to take

Not if you use relative height (something like height: screen.height-otherstuff.height)

Quote:

Originally Posted by marmistrz (Post 1237397)
Is it possible to specify an animation for this?

Yes, look up one of the examples on how to create animations on property changes. You probably want to use the animation on opacity from 0 to 1, or on height.

Quote:

Originally Posted by marmistrz (Post 1237397)
How can I get the default height of a button?

I think it's in ButtonStyle object.

marmistrz 2012-07-17 19:44

Re: QML and SelectionDialog [and other QML-related questions]
 
Quote:

Originally Posted by Slocan (Post 1238878)
Not if you use relative height (something like height: screen.height-otherstuff.height)

Yes, look up one of the examples on how to create animations on property changes. You probably want to use the animation on opacity from 0 to 1, or on height.

I think it's in ButtonStyle object.

Is it possible to use ButtonStyle without creating any object (as if these were static properties)?

I have another problem.

I have this class:

Code:

typedef QString lyricsDownloaderString;

class lyricsDownloader : public QObject
{
public:
    Q_INVOKABLE virtual short perform() = 0;
    Q_INVOKABLE inline void setData(const string & a, const string & t); // set artist and track
 // some other data

protected:
    lyricsDownloader(const string & a, const string & t ) : artist(a), track(t) {}
  /*other data*/
};

class AZLyricsDownloader : public lyricsDownloader
{
public:
    AZLyricsDownloader() : lyricsDownloader("", "") {}
    AZLyricsDownloader(const string & a, const string & t) : lyricsDownloader(a, t) {}
    Q_INVOKABLE short perform();
    Q_INVOKABLE inline void setData(const string & a, const string & t);// set artist and track
 /*other data*/

In main.cpp
Code:

Q_DECL_EXPORT int main(int argc, char *argv[])
{
        QApplication app(argc, argv);

        mainWindow viewer;

        qmlRegisterUncreatableType<lyricsDownloader>("MaeLyrica", 1, 0, "lyricsDownloader", "");
        qmlRegisterType<AZLyricsDownloader>("MaeLyrica", 1, 0, "AZLyricsDownloader");
        viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
        viewer.setMainQmlFile(QLatin1String("qml/maelyrica/main.qml"));
        viewer.showFullScreen();

        return app.exec();
}

in main.qml

Code:

import QtQuick 1.1
import com.nokia.meego 1.0
import com.nokia.extras 1.0
import MaeLyrica 1.0

//property color fontcolor: "white"

PageStackWindow
{
    id: pagestackwindow
    visible: true
    MainPage
    {
        id: mainview
    }
    initialPage: mainview
    AZLyricsDownloader
    {
        id: azdownloader
    }
}

And in one of the pages

Code:

import QtQuick 1.1
import com.nokia.meego 1.0

Page
{
 /*some gui elements*/

        Button
        {
            id: go
            text: "Go!"
            width: parent.width
            onClicked:
            {
                goLoader.source = "ShowLyricsPage.qml"
                pageStack.push(goLoader.item)
                azdownloader.perform()
                showLyricsPage.busyind.visible = false
            }
        }
    }
/*dialogs and toolbar definitions*/
}

Code:

import QtQuick 1.1
import com.nokia.meego 1.0

Sheet {
    id: sheet

    acceptButtonText: "Save"
    rejectButtonText: "Cancel"
    onAccepted:
    {
        if ( artistfield.text == "" || trackfield.text == "" ) // check whether empty
        {
            emptyfieldsdialog.open()
        }
        else
        {
            selecttrack.text = artistfield.text + " - " + trackfield.text
            azdownloader.setData(artistfield.text, trackfield.text)
        }
    }

    content: Rectangle { /*some content here*/ }

    /*dialog definition*/

Although I marked functions as Q_INVOKABLE, I'm getting
Code:

TypeError: Result of expression 'azdownloader.setData' is not a function
TypeError: Result of expression 'azdownloader.perform' is not a function

What am I doing wrong?

EDIT: I forgot to add Q_OBJECT macro


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

vBulletin® Version 3.8.8