PDA

View Full Version : Qt Creator plugin: how to insert foreign widgets from my plugin into QtQuick Designer



mut
23rd May 2014, 17:19
Hello;

I'm building a plugin for Qt Quick Designer.

I was able to successfully create the basic Qt Creator plugin (http://doc.qt.digia.com/qtcreator-ex...st-plugin.html). Now I want to embed foreign widgets (W1, W2, W3, W4) from my plugin into QtQuick Designer itself. Obviously, I need to dig into QtQuick designer source code.

These foreign widgets are W1, W2, W3, W4, please see the attached file for their intended location.
W1: same nature as “Welcome”, “Design”, “Debug”, “Projects”, “Analyze”, “Help”. They will have the same parent.
W2: ToolBox Widget. It will be a selectable item in the “Library” dropdown list
W3: QGraphicsView. It will be a selectable item in the “main.qml” dropdown list
W4: QTabWidget: It will be a selectable item in the “Open Documents” dropdown list

My questions:
1) I have the entire source code of Qt Creator but I’m unable to locate the code for W1?
2) Where is the source code of the above refered dropdown lists? how these dropdown lists will interface with my code?
3) How to ensure that W2,W3, W4 occupy the same area as their parent and are resizable with them?
4) How do Qt Quick Designer code will call/interface with my code?

Thank you for your help.

Mut

tom.hedden
24th May 2014, 18:19
What do you mean by "foreign widgets"? Surely you don't mean widgets containing foreign language text?
You should be able to do that without any trouble. Just type the foreign language text in the appropriate
place. Many widgets such as buttons allow you to double-click on them and enter the text in WYSIWYG mode.
Or do you mean something else?
Tom

mut
30th May 2014, 06:19
Hi Tom
Thank you for the reply.
The word "foreign" should not be here. What I m asking is how to incorporate Qt creator classes in my qt Creator plug in? how to interface the two ( q creator and my qt creator plug in)?

wysota
30th May 2014, 07:42
Do you want to extend Qt Quick Designer or substitute it with your own?

mut
9th June 2014, 02:15
Yes, I'm writing a Qt Quick designer plugin. Within my code: I need to add my items into these Qt Quick designer objects:

- Object1: “Welcome”, “Design”, “Debug”, “Projects”, “Analyze”, “Help” vertical tab bar.
- Object2: “Library” dropdown list
- Object3: “main.qml” dropdown list
- Object4: “Open Documents” dropdown list

Thanks

mut
9th June 2014, 02:31
Hello;

I'm building a plugin for Qt Quick Designer.

I was able to successfully create the basic Qt Creator plugin (http://doc.qt.digia.com/qtcreator-ex...st-plugin.html). Now I want to access the QtQuick Designer classes exposed by the PlugIn Manager. I need to access the following QCreator and QtQuick designer objects from my code:

- Object1: The vertical tab bar of QtCreator. This is the tab bar is already containing “Welcome”, “Design”, “Debug”, “Projects”, “Analyze”, “Help”.
- Object2: “Library” dropdown list in Qt Quick Designer.
- Object3: “main.qml” dropdown list Qt Quick Designer.
- Object4: “Open Documents” dropdown list Qt Quick Designer.

I'm not sure how to do that?

Thank you for your help.

Mut

mut
9th June 2014, 02:40
Hello;

I'm building a plugin for Qt Quick Designer.

I want to know the objects in pluginmanager that belong to Qt Quick Designer in order to access them in my own code?

In particular: how to add items and handle selection for the case of these UI objects:

- Object1: “Library” dropdown list
- Object2: “main.qml” dropdown list
- Object3: “Open Documents” dropdown list

Thanks;

Mut

wysota
9th June 2014, 08:49
Yes, I'm writing a Qt Quick designer plugin. Within my code: I need to add my items into these Qt Quick designer objects:

- Object1: “Welcome”, “Design”, “Debug”, “Projects”, “Analyze”, “Help” vertical tab bar.
- Object2: “Library” dropdown list
- Object3: “main.qml” dropdown list
- Object4: “Open Documents” dropdown list


You did not answer my question:


Do you want to extend Qt Quick Designer or substitute it with your own?

Which of the two is it?

mut
9th June 2014, 15:24
Hello;

I'm building a plugin for Qt Quick Designer.

I want to know the objects in pluginmanager that belong to Qt Quick Designer in order to access them in my own code?

In particular: how to add items and handle selection for the case of these UI objects:

- Object1: “Library” dropdown list
- Object2: “main.qml” dropdown list
- Object3: “Open Documents” dropdown list

Thanks;

Mut http://doc.qt.digia.com/qtcreator-extending/first-plugin.html

mut
9th June 2014, 15:32
Thanks for the follow up. I want to extend Qt Quick Designer.

mut
9th June 2014, 15:44
Hello;

I'm building a plugin for Qt Quick Designer.

I was able to successfully create the basic Qt Creator plugin (http://doc.qt.digia.com/qtcreator-ex...st-plugin.html). I want to list all the exposed objects of PlugInManager in order to track the ones
related to QML designer.

Here my code:
#include "C:\qt-creator-opensource-src-3.1.0\src\libs\extensionsystem\pluginmanager.h"

ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
QList<QObject*> objects = pm->allObjects();
foreach(QObject* obj, objects)
{
QString objInfo = QString(QString::fromStdString("%1 (%2)"))
.arg(obj->objectName())
.arg(QString::fromStdString(obj->metaObject()->className()));
qDebug() << objInfo;
}

I'm getting this crash at compile time:
error: undefined reference to `_imp___ZN15ExtensionSystem13PluginManager8instanc eEv'
error: undefined reference to `_imp___ZN15ExtensionSystem13PluginManager10allObj ectsEv'
:-1: error: release/main.o: bad reloc address 0x20 in section `.text$_ZN7QStringD1Ev[__ZN7QStringD1Ev]'

Thanks;

Mut

wysota
9th June 2014, 16:42
I don't think Qt Quick Designer plugin is tailored to handle sub-plugins. You can easily verify that by seeing if the plugin tries to fetch a list of objects in its extensionsInitialized() method.

mut
9th June 2014, 17:59
Hi
Thank you very much for the reply. I'm not sure what you mean by "the plugin tries to fetch a list of objects....". What I have done is to try to list all the objects exposed by the QML Designer plugin in the QCreator pluigin manager. I have tried this code in a sample widget app, but it fails.

Here my code:
#include "C:\qt-creator-opensource-src-3.1.0\src\libs\extensionsystem\pluginmanager.h"

ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
QList<QObject*> objects = pm->allObjects();
foreach(QObject* obj, objects)
{
QString objInfo = QString(QString::fromStdString("%1 (%2)"))
.arg(obj->objectName())
.arg(QString::fromStdString(obj->metaObject()->className()));
qDebug() << objInfo;
}

I'm getting this crash at compile time:
error: undefined reference to `_imp___ZN15ExtensionSystem13PluginManager8instanc eEv'
error: undefined reference to `_imp___ZN15ExtensionSystem13PluginManager10allObj ectsEv'
:-1: error: release/main.o: bad reloc address 0x20 in section `.text$_ZN7QStringD1Ev[__ZN7QStringD1Ev]'

mut
10th June 2014, 02:23
Hello;

I'm writing an extension plugin for QML designer.

Hence I need to access the UI objects in QmlDesigner::QmlDesignerPlugin ?

I'm trying to run the following code from my Qt Creator plugin:
QmlDesigner::Internal::DesignModeWidget *p = QmlDesigner::QmlDesignerPlugin::instance()->mainWidget();

Problem is that the above piece of code fails with:

-1: error: undefined reference to `_imp___ZN11QmlDesigner17QmlDesignerPlugin8instanc eEv'
-1: error: undefined reference to `_imp___ZNK11QmlDesigner17QmlDesignerPlugin10mainW idgetEv'

Help will be very much appreciated.

Thanks;

Mut.

wysota
10th June 2014, 06:52
Hi
Thank you very much for the reply. I'm not sure what you mean by "the plugin tries to fetch a list of objects....".
I mean exactly what I wrote -- see if the plugin gets some list of objects in its extensionsInitialized() method. If you don't understand such a simple thing then I have no idea how you intend to write a plugin that extends Qt Quick Designer.

After having a quick look at the current repository (https://qt.gitorious.org/qt-creator/qt-creator/source/76f829164a5e2a2eb8371dc5dbdd8909b57b21ea:src/plugins/qmldesigner/qmldesignerplugin.cpp) one can see that extensionsInitialized() doesn't expect any objects in the object pool to be available and the only object it exposes itself is its settings pane. So I guess you are out of luck and you will have to modify the plugin's code directly.


I'm getting this crash at compile time:
error: undefined reference to `_imp___ZN15ExtensionSystem13PluginManager8instanc eEv'
error: undefined reference to `_imp___ZN15ExtensionSystem13PluginManager10allObj ectsEv'
:-1: error: release/main.o: bad reloc address 0x20 in section `.text$_ZN7QStringD1Ev[__ZN7QStringD1Ev]'
It is not a crash, it is a linking error as you are probably not linking to some needed library (e.g. the core plugin of Qt Creator).

mut
10th June 2014, 22:44
Thanks for the reply. Your are right. This is the list of QML related exposed objects in the Qt Creator Plug In Manager:

" (QmlJSTools::Internal::QmlConsolePane)"
" (QmlJSTools::Internal::LocatorData)"
" (QmlJSTools::Internal::FunctionFilter)"
" (QmlJSTools::Internal::QmlJSCodeStyleSettingsPage)"
" (QmlJSTools::BasicBundleProvider)"
" (QmlJSEditor::Internal::QmlJSHighlighterFactory)"
" (QmlJSEditor::Internal::QmlTaskManager)"
" (QmlJSEditor::Internal::QmlJSEditorFactory)"
" (QmlJSEditor::QmlFileWizard)"
" (QmlJSEditor::QmlFileWizard)"
" (QmlJSEditor::JsFileWizard)"
" (QmlJSEditor::Internal::QmlJSCompletionAssistProvi der)"
" (QmlJSEditor::Internal::HoverHandler)"
" (QmlJSEditor::QmlJSQuickFixFactory)"
" (QmlJSEditor::QmlJSQuickFixFactory)"
" (QmlJSEditor::QmlJSQuickFixFactory)"
" (QmlJSEditor::QmlJSQuickFixFactory)"
" (QmlJSEditor::Internal::QmlJSOutlineWidgetFactory)"
" (QmlJSEditor::QuickToolBar)"
" (QmlJSEditor::Internal::QuickToolBarSettingsPage)"
" (QmlDesigner::Internal::SettingsPage)"
" (QmlProfiler::Internal::QmlProfilerRunControlFacto ry)"
" (QmlProjectManager::Internal::Manager)"
"QmlProjectRunConfigurationFactory (QmlProjectManager::Internal::QmlProjectRunConfigu rationFactory)"
" (QmlProjectManager::Internal::QmlApplicationWizard )"

Added after 14 minutes:

However, I implemented
class MyNavWidgetFactory : public Core::INavigationWidgetFactory
{
public:
MyNavWidgetFactory ();
~MyNavWidgetFactory();

virtual QString displayName() const;
virtual int priority() const;
virtual Core::Id id() const;
virtual Core::NavigationView createWidget();
};

I works but it does not reach QML designer even if I see that QML designer uses this factory?

wysota
11th June 2014, 08:09
I works
In what way does it "work"?


but it does not reach QML designer
What do you mean? How would it "reach" QML Designer?


even if I see that QML designer uses this factory?

How do you see that?

mut
11th June 2014, 16:17
At the top of the thread I have attached an image of the QML designer dropdown list in which I want to add items. This what I means by reaching QML designer.

Added after 15 minutes:

It works means that the navigation widget shown below becomes populated with my new item MyNavWidgetFactory:

10411

mut
11th June 2014, 22:44
Hi Sorry. There is a change in my requirements. I no longer need go up to QML Designer, now I'm staying in core Qt Creator. I just need to add another tab (W1 in the image at the top of this thread and also inserted here) in the vertical tab widget containing “Welcome”, “Design”, “Debug”, “Projects”, “Analyze”, “Help”. The new tab page should be after Help and once selected W2, W3 and W4 should be displayed.
10413

wysota
12th June 2014, 07:30
At the top of the thread I have attached an image of the QML designer dropdown list in which I want to add items. This what I means by reaching QML designer.

Added after 15 minutes:

It works means that the navigation widget shown below becomes populated with my new item MyNavWidgetFactory:

10411

It still doesn't tell me what you want and what actually happens.