Qt Designer doesn't load my custom widget plugin - c++

I'm reading the book "C++ GUI Programming with Qt4", and I've reached the topic of Integrating Custom Widgets with Qt Designer.
I've built the example project outlined there (the icon editor plugin), and I get a file called 'libiconeditorplugin.so', and I've copied it to '/usr/lib/qt4/plugins/designer/'. But when I start Qt Creator I don't see the icon editor widget in the widget box.
The only thing I've done differently from the book is I removed the DESTDIR from the .pro file because it had $QTDIR, and $QTDIR is not defined in my computer and I don't know where it should point. Instead, I copied the .so file manually.
I'm not sure if I've copied the plugin in the right directory, and if libiconeditorplugin.so is the only file that I needed to copy, the book was kind of sketchy on how it should work.
My OS is Ubuntu and I've installed Qt Creator with apt-get.

Turns out I was copying libiconeditorplugin.so to the wrong directory. I was copying it to "/usr/lib/qt4/plugins/designer/", while Qt Designer was looking in "/usr/lib/x86_64-linux-gnu/qt4/plugins/designer/".

Related

Qt Charts and Data Visualization widgets

I have installed Qt 5.7 in order to try Qt Charts and Qt Data Visualization but I cannot find new widgets neither in Qt Designer nor in Qt Creator. Any suggestions what should I do so new widgets appear in designer?
I was having exactly the same problem today. It looks like the QT Designer plugins of QT Charts are not part of the package by default. I ended up downloading the designer plugin sources from github https://github.com/qtproject/qtcharts/tree/5.7/plugins/designer
This consists of just 5 files.
You should then be able to open the designer.pro project in Qt Creator and compile it. Place the resulting library in your designer plugin directory. This will make the QChartsView widget appear in the Qt Designer.
Just elaborating on Holger's answer for ubuntu, compile, in terminal using qmake and make (doesn't work in qt creator - you need qt chart development package installed, which I believe is not available at this point in time), the designer.pro file in /opt/Qt/5.7/Src/qtcharts/plugins/designer directory then, copy and paste the shared library into /opt/Qt/Tools/QtCreator/lib/Qt/plugins/designer directory, where /opt/Qt is the directory in which Qt is installed.
I would like to add this as a comment to the accepted post:
If you are using python to build your project and process the .ui files with pyuic5 it might be the case that pyuic5 leaves you with an error message stating that QtChart.QChartview could not be found. This is the workaround:
Go to the site-packages/PyQt5/uic/widget-plugins directory, it should look something like this:
/widget-plugins/
__pycache__/
qaxcontainer.py
qscintilla.py
qtcharts.py <- create this file by copying qtquickwidgets.py and renaming
qtprintsupport.py
qtquickwidgets.py
qtwebkit.py
qtcharts.py looks like this (you have to edit the file):
# copyright information
pluginType = MODULE
def moduleInformation():
return "PyQt5.QtChart", ("QChartView", )
I also encountered this problem today, but Holger's way didn't work on my situation. After consulting other people via internet, I finally fixed it. And my solution is quiet simple, I just open the Maintenance Tool and choose add components, select Qt Charts and Qt Data Visualization, and click next, and then it works. This problem happens because by default Qt Charts is not selected while installing Qt, so we should add this component manually.
But I also should mention that maybe this way just work on Qt which was installed by Qt Online Installer, and if you installed Qt via offline Installer, maybe you should reinstall it.

Deploying Qt QML Compiled Executable

So I have a simple app that uses QML for my graphical interface and c++ code for some of the logic. I was looking for a method to compile the QML into c++ code and link it into my binary and found this page over at the Qt home site:
http://doc.qt.io/QtQuickCompiler/
Basically it says use the resource system for all of my QML graphical interface files and add the QML compiler flag to my qmake config line in my .pro file and everything should be good to go.
As far as I know everything compiles fine, but when I use the the Qt windeployqt.exe tool to get all of the dependency files and test it on a clean system, I get a small white screen as if my QML files were not loaded properly.
I have one c++ reference to my main QML file using "qrc:/mainqml.qml" and that's it.
Any idea what I am doing wrong?
You're using the open source version of Qt. It didn't come with the Qt Quick compiler until Qt 5.11 where it is included - and after a rework, too. So it performs better than precompiled QML did in Qt 5.10 and before.
I get a small white screen as if my QML files were not loaded properly.
... thus you need to deploy these files with the application, otherwise it won't work.
add the QML compiler flag to my qmake config
That flag was a no-op on an open source Qt build until Qt 5.11.
Qt Quick Compiler only shipped with Qt Commercial License, but you can still compile your QML files into qrc file. Starting a Qt Quick application project from Qt Creator does exactly this.
Deploying QML application with windeployqt require additional flag --qmldir, e.g.
windeployqt --(release or debug) --qmldir %PATH_TO_YOUR_QML_FILES% %YOUR_APPLICATION%.exe
It will parse your qml files and deploy all qml imports you used.

Import form from Qt Designer to my Project in Qt Creator

I created a Form with my Qt Designer. Now I want to import it to my Qt Creator Project but I couldn't find any Import-buttons...
Does anyone know how to import an existing file made with QT Designer to Qt Creator to my project? Or is there any way to copy everything I made with QT Designer to a Form in Qt Creator?
Suppose the form you created by Qt-Designer is a file called myform.ui.
Just copy it into your Qt project, beside other files.
Then right-click on the project and choose "Add Existing Files...", select myform.ui.
That's all.
The easiest way I found is to do this...
Create a new window in your QT Creator project. Example: new_window.ui
Go to QT Designer, File>Save As and then overwrite "new_window.ui" with your UI.
It will work the same even if you're starting a new project.

QCreator designer widget inaccessible from program code

Preface: I am using Qt Creator 2.4.1 (based on Qt 4.7.4, 64-bit) on Mac OS X Lion installed via the Qt SDK.
I am working on a project where I have a UI created using the designer in QCreator. I have several widgets working without issue. I created a new QPushButton widget by dragging it from the desiger palette and set some properties in the designer. However, I am unable to access it from the source code using the ui->[widget] convention. I can access every other widget on the form as expected. A search of the site yielded one similar issue, however the solution specified does not work for me.
I've tried:
Clean, full rebuild
Re-running qmake
Restarting QCreator
I have checked the ui element's generated XML and the widget is included and with the correct objectName and properties, yet the source code portion of the designer does not see it.
I solved this issue by deleting the current working directory, checking out the latest source from version control, and creating a new project. After further scrutiny, I found that ui_mainwindow.h, which is generated every compile by qmake, had been moved into the source directory instead of the build directory, which must have caused some internal conflict with QCreator where it would not regenerate it and just copy the old one to the build folder. Deleting the file probably would have worked if I had seen it and saved me the time of starting fresh.

Need Qt Creator Source files

I want to create a similar GUI as Qt Creator main layout and thus I am looking for Qt Creator Source files.
Can anyone direct me from where to download.
Have a look at the gitorious repo: http://qt.gitorious.org/qt-creator