Why can't I import my own Qt module? - c++

So, I'm creating an app in QML, and have created a custom component. To be better organized, I am placing all of my custom components in a "com" subdirectory. I did some research, and found that I needed QML_IMPORT_PATH and a custom qmldir file to create a module so I could import my controls into my project.
My components path is E:/Qt Projects/MyApp/qml/MyApp/com
Inside, I created a qmldir.txt file containing the following:
Button 1.0 Button.qml
Where "Button.qml" is the name of my custom component (in the same directory).
//Button.qml
import QtQuick 1.1
Rectangle {
width: 100
height: 50
}
Next I went to "MyApp.Pro" and appended the following:
QML_IMPORT_PATH = E:/Qt Projects
Finally, I went to MyApp.qml and added:
import MyApp.qml.MyApp.com 1.0
Yet, I am still getting a "module not found" error on that line. When it shows the error during mouseover, it displays a list of the current import paths, and E:/Qt Projects wasn't one of them. I've cleaned, rebuilt my project, ran qmake and everything. Still not working. Is my syntax wrong? Why won't it find my module? I'm a Qt newbie so forgive me if this is a stupid question. Any help is appreciated. Thanks in advance.

Related

Using amplify react components in a Svelte-kit project

I've been trying to import and use #amplify/ui-react componetns inside a svelte kit file.
However, when I import the components i get the error:
"Cannot use import statement outside a module"
My code is shown below, and the error only occurs while the import {authenticator} line is present. Meaning its unique to ui-react components.
I've tried messing around with files and extensions, aswell as differnet component versions but I can't seem to shake this error. Any help with this would be greatly appreciated.
Code
error

ModuleNotFoundError: No module named 'config.wsgi'

I'm trying to run a .py file and in the file I have this import
from config.wsgi import *
import os
from django.template.loader import get_template
from weasyprint import HTML, CSS
from config import settings
The whole project works, if I set runserver, the project starts without any problem, but this file does not work. The structure of the project is as follows
NombreDelProyecto
--app
---config
----__init__.py
----asgi.py
----settings.py
----wsgy.py
----db.py
---core
----general
----login
----user
----archivodetest.py
the case as I say the project works, but in the views of the applications that I have been doing to put imports I get in red underlined but as I say it works for example:
from core.general.forms import ActividadForm
That comes out in red, if I put in front of the core, app.core as follows
from app.core.general.forms import ActividadForm
it does not show red but the project does not work and I get the following error
from app.core.general.forms import ActividadForm
ModuleNotFoundError: No module named 'app'
I understand that it is the routes or something I did wrong from the beginning, please could someone help me.
Thank you very much.
I tried adding the route, changing the app's route in settings, but to no avail.
You've named the file wsgy.py but it needs to be wsgi.py.
Rename your file in config and retry.
To your question, I think its because you're missing the __init__.py file in the general app.
If you haven't already go one, you'll likely need to have add the same again in your core app too.
You probably manually created all of these files and structures I suspect, and if that's the case, please take a look at the documentation regarding creating new apps inside a django project.
If you go a bit further up the page, it will also tell you how to create the initial django project structure with a command.
Thank you very much for the answer, I managed to solve it after a lot of testing.
There are two ways, open the project again from the app folder (I had it open in the ProjectName folder).
Or as a second option in pyCharm on the left where the project folders are, I went to the app folder (which is the root) and right clicked and in the menu, Mark Directorie as - Sources root. Then my problem is fixed.
I had all the arcvhiso init.py, and where I put the wrong name wsgi.py is that I wrote it wrong here but in the project it was right.
Thank you very much for the help.

Fail to import QML module using CMake

I'm currently building a minimalist app following this CMake architecture:
-root
--QmlModule
---Component1.qml
---Component2.qml
--App1
---main.cpp
---main.qml
--App2
---main.cpp
---main.qml
I use "qt6_add_qml_module" to create a QML module at "QmlModule" level as a STATIC library.
qt_add_library(myComponentTarget STATIC)
qt6_add_qml_module(myComponentTarget
URI QmlModule
VERSION 1.0
QML_FILES
Component1.qml
Component2.qml
RESOURCES
logo.png)
Then, at App1 (and App2) level, a link to the module is done using "target_link_libraries". "qt6_add_qml_module" does some work behind the scenes in order to expose the module trough an automatically generated plugin named "your_component_URIplugin". More details about this here.
add_executable(App1Exe
main.cpp)
qt6_add_qml_module(App1Exe
URI App1
VERSION 1.0
QML_FILES
main.qml)
target_link_libraries(App1Exe
PRIVATE
myComponentURIplugin)
At Root level, I overload QML_IMPORT_PATH in order to link to the build folder and add all subdirectories.
set(QML_IMPORT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/qmlModule)
add_subdirectory(QmlModule)
add_subdirectory(App1)
add_subdirectory(App2)
I run CMake without any errors, and open App1/main.qml file.
On my import QmlModule, the module can't be found:
module "lupinComponentsplugin" is not installed
How to make my module visible from my Apps ?
What step am I missing ?
I'm currently doing something similar.
I have created a demo app where I import modules. The modules provide QML and C++ items to the main app. Check the comments in the CMAKE files to find out how this works.
Here is the link:
https://gitlab.com/basic53/DemoApp
Feel free to comment on this.
Another tip: If qt_add_qml_module is not working properly, sometimes it is necessary to remove the whole build folder and update the QML code model. You can check the generated files to see, if your plugin has been created with all its types.
CMake itself was fine, this was a runtime error and not a link error.
This issue was raised because the QQmlApplicationEngine wasn't finding path towards my module's QMLDIR.
In the end, the only thing missing was an additional import path ":/" in QQmlEngine:
QQmlApplicationEngine engine;
engine.addImportPath(":/");

Ionic2 - How to import css files for a page component

I have to import some stylesheets residing inside node_modules (bootstrap.css from node_modules, etc).
I tried by
adding styleUrls inside #Page,
putting the styles in the .scss file inside the page component folder,
and finally putting the styles inside the template file itself by creating new style tag... all with no luck, i.e the required styles are not getting applied on tags with appropriate classes.
How to do this ?
PN: I had imported the page scss for my components in app.core.scs.
Anyways, I think putting bootstrap.min.css inside page scss is not a
good way
Adding the above import doesn't seem to work in the latest version of Ionic2 (ionic -version = 2.1.4) that I installed on 10/25/16. There is no longer an app.core.scss file in newly created projects. But rather just variables.scss in src/app/theme.
There is a file app.scss in src/app that says it's for global SASS and importing other files, but adding an import for another page does not seem to make a difference.
I have a page /src/app/pages/about, in which I have about.ts that has styleUrls: ['about.scss']. The file about.scss is in the same directory. Putting #import "../pages/about/about"; at the bottom of that file makes no difference.
UPDATE:
I have finally got it to work with this in about.ts:
styleUrls: ['/pages/about/about.scss']
I'm not sure if this is the best way yet, but it works for now.
#import "../pages/yourpage/yourpage"
Add this line in app/themes/app.core.scss and rebuild. Of course change yourpage expression.

PyCharm/Django - cannot import module views.py (IDE is wrong)

I'm having a weird problem with import views in Django project. I'm not sure whether it is a problem caused by PyCharm of Django. So PyCharm says that it can't import views.py file, but it works when I run the server.
Here is the picture:
Do you know where could be the problem?
EDIT:
According to Inlangers answer, I've tried to change import to from vlado_web.translations import views which did not helped, moreover, it raises
Exception Value:
No module named translations
When I have from translations import views there, it works correctly but PyCharm says that it can't be resolved.
PyCharm doesn't know where your source files are. Try this:
Right click on folder vlado_web (the folder that contains manage.py) within PyCharm. Go to Mark Directory As and choose Sources Root.
This will let PyCharm know that the vlado_web directory is the root folder for your source code, and will allow you to perform absolute imports from there, e.g.
from vlado_web.translations import views
Try from vlado_web.translations import views