Problem with plugins
-
Which part isn't working? Still the QML?
How are you running the QML file? QMLViewer?
Does your directory look like this?
@
.
..
app.qml
qmldir
lib\elipseplugin.dll
@
P.S. Won't change anything but should be using (new notation):
@import QtQuick 1.0@ -
Yes, the file structure is like you said, and I'm running with QMLViewer, but the plugin from the examples works fine with QMLViewer.
-
Do you remember what you changed?
You could try running adiff
between your directory and the original plugin. -
You didn't provide the implementation of Elipse (elipse.cpp), but a common mistake (at least for me) is clearing the QGraphicsItem::ItemHasNoContents flag which is set by QDeclarativeItem.
Works for me with the files above, plus these:
main.qml
@
import Qt 4.7Rectangle {
width: 100
height: 62Elipse { anchors.fill: parent color: "red" }
}
@elipse.cpp
@
#include "elipse.h"#include <QtGui/QPainter>
Elipse::Elipse(QDeclarativeItem *parent) :
QDeclarativeItem(parent)
{
setFlag(QGraphicsItem::ItemHasNoContents, false);
}Elipse::~Elipse() {}
QColor Elipse::color() const { return m_color; }
void Elipse::setColor(const QColor &color) { m_color = color; }QColor Elipse::border_color() const { return m_border_color; }
void Elipse::setBorderColor(const QColor &border_color) { m_border_color = border_color; }int Elipse::border_size() const { return m_border_size; }
void Elipse::setBorderSize(const int &border_size) { m_border_size = border_size; }void Elipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
painter->setPen(QPen(m_border_color, m_border_size));
painter->setBrush(m_color);
painter->drawEllipse(boundingRect());
}
@ -
I have same trouble. Can anybody tell me stap-by-stap "howto" ?
-
I have the same troubles.
For me the main problem is to understand how to correctly import the plugin to the application.If the plugin is in another location than the application, how do you tell the build system were to look ?
Since I have several targets (simulator, device...) + release (debug, release...), I have different version of my plugin library in different folders. How does the build system makes the difference ? -
In your .pro you can specify it depending on target and other such variables.
symbian: { ...}
win32: { ... } -
I know what you mean, however if I understand the docs correctly, importing a plugin does not involve the .pro at all
From the docs, the only thing you have to do is to add "import MyPlugin 1.0" at the top of the QML file in which you want to use the plugin.
http://doc.qt.nokia.com/latest/qdeclarativeextensionplugin.html -
Your .pro is basically a shell script where you can configure which files are used. From the .pro you can effectively specify which plugin will be MyPlugin.
-
This is mentionned nowhere in the docs about using plugins, nor in the QMake doc. There don't seems to have any command related to QML Plugins in QMake.
Would you mind beeing a little bit more specific ? -
In your .pro, you can specify source files to compile (eg. symbian: { ... HEADERS+=myplugin.h .. }, you can specify plugins to add (eg. symbian: { folder_01.source = symbian/plugin \ folder_01.target = symbian \ DEPLOYMENTFOLDERS = folder_01 }) and so on.
I mean that you can change the file structure with your .pro which will affect which plugin you import. I believe this is generally how multiple platforms are handled.
Otherwise, you can have defines for Q_WS_XX in source code or even entirely different QML files for each platform.
#ifdef Q_WS_S60
v.setMainQML("qrc:/symbian.qml");
#endifThere's many choices.