How to get QWebEngine in QT Designer - qt

I am trying to make a program for captioning youtube videos because they removed the community captions functionality last year. I want to be able to use the QWebEngine widget when in QT Designer but it isn't part of the main distribution and I cannot find the steps to install it on Windows.

C++
The problem is similar to this post but instead of QChartView you want QWebEngineView so my answer will be more concise and I will only point out the changes:
Promoted
First add QT += webenginewidgets in the .pro
Place the QWidget to the design.
Right click on the QWidget and select Promote to...
When doing the above, a menu appears, in the menu it should be set in QWebEngineView in Promoted Class Name, and QWebEngineView in Header file, then press the add button and finally press promote.
Plugin
You must clone the repository using the branch of your Qt version, in the example I will use Qt 5.15.2, then you must compile the plugin and install it:
git clone -b 5.15.2 https://code.qt.io/qt/qtwebengine.git
cd qtwebengine/src/plugins/qwebengineview
qmake .
make
make install
If you don't want to clone the project then you could download the files from here and run qmake, make and make install.
Python
It seems that the OP is using python and not C++ so the first solution has another methodology, but the second method still works as it installs the plugin for QtDesigner. Considering the above I am going to show simple methods to integrate QWebEngineView in QtDesigner.
Promoted
You just have to use steps 2 to 4 but setting the header "PyQt5.QWebEngineWidgets", and for example you will get the following:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWebEngineView" name="widget"/>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>28</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<customwidgets>
<customwidget>
<class>QWebEngineView</class>
<extends>QWidget</extends>
<header>PyQt5.QWebEngineWidgets</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
If you are going to use PySide2 then just change it to PySide2.QtWebEngineWidgets.
Container
Another simpler option is to use QWidget as a container and then use a layout to place it.
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="widget" native="true"/>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>28</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
import os
from pathlib import Path
from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.uic import loadUi
CURRENT_DIRECTORY = Path(__file__).resolve().parent
class Widget(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
filename = os.fspath(CURRENT_DIRECTORY / "gui.ui")
loadUi(filename, self)
lay = QVBoxLayout(self.widget)
self.webview = QWebEngineView()
lay.addWidget(self.webview)
def main():
import sys
app = QApplication(sys.argv)
w = Widget()
w.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()
Note: Promoting a widget does not allow modifying the widget's properties in QtDesigner, only that it can be used when the .ui is loaded into the project.

Related

Cant select Qt kit

I've recently installed Qt, and I am trying to make a project, but I need to select a kit to continue making the project, however, the two kits that are shown are greyed out and I don't know how to select them.
Its a QtWidgets project saved in documents
Build System is qmake
Class Name is MainWindow
Base Class is QMainWindow
Header File is mainwindow.h
Source File is mainwindow.cpp
Form File is mainwindow.ui
What the screen looks like:
Do I need to install anything? Or have special configurations? Thanks
My workaround for this is to open a blank file, save it as filename.ui, and fill it with this:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ClassName</class>
<widget class="QWidget" name="ClassName">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>553</width>
<height>520</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"/>
</widget>
<resources/>
<connections/>
</ui>
Then I right click the file and select "open in QT Creator"

Unable to login with users in Active Directory in wso2 api manager

I've configured the wso2 api manager with external LDAP i.e. Microsoft Active Directory. Connectivity is set up and I'm able to see all the users in WSO2 apim user store which are present in AD. I have 4 following users in AD
Users : WSo2 Admin, WSO2 User1, WSO2 User2
But I'm able to login with just one user which I'm assigning the admin role in configuration file like below snippet.
<AdminUser>
<UserName>Wso2 Admin</UserName>
<Password>abcdef#01</Password>
</AdminUser>
Now I'll be only able to login with WSo2 Admin only, same happens for other users if I assign admin role in config file I'll be able to login.
But i want to login with every user which are present in AD i.e. WSo2 Admin, WSO2 User1, WSO2 User2
Here is my configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<UserManager>
<Realm>
<Configuration>
<AddAdmin>false</AddAdmin>
<AdminRole>admin</AdminRole>
<AdminUser>
<UserName>Wso2 Admin</UserName>
<Password>abcdef#01</Password>
</AdminUser>
<EveryOneRoleName>everyone</EveryOneRoleName>
<!-- By default users in this role sees the registry root -->
<Property name="isCascadeDeleteEnabled">true</Property>
<Property name="initializeNewClaimManager">true</Property>
<Property name="dataSource">jdbc/WSO2CarbonDB</Property>
<UserStoreManager class="org.wso2.carbon.user.core.ldap.ActiveDirectoryUserStoreManager">
<Property name="TenantManager">org.wso2.carbon.user.core.tenant.CommonHybridLDAPTenantManager</Property>
<Property name="ConnectionURL">ldap://test.xxxx.com:389</Property>
<Property name="ConnectionName">CN=Wso2 Admin,OU=wso2test,DC=test,DC=xxxx,DC=com</Property>
<Property name="ConnectionPassword">abcdef#01</Property>
<Property name="AnonymousBind">false</Property>
<Property name="UserSearchBase">OU=wso2test,DC=test,DC=xxxx,DC=com</Property>
<Property name="UserEntryObjectClass">user</Property>
<Property name="UserNameAttribute">cn</Property>
<Property name="UserNameSearchFilter">(&(objectClass=user)(cn=?))</Property>
<Property name="UserNameListFilter">(objectClass=user)</Property>
<Property name="DisplayNameAttribute"/>
<Property name="ReadGroups">true</Property>
<Property name="WriteGroups">true</Property>
<Property name="GroupSearchBase">OU=wso2test,DC=test,DC=xxxx,DC=com</Property>
<Property name="GroupEntryObjectClass">group</Property>
<Property name="GroupNameAttribute">cn</Property>
<Property name="GroupNameSearchFilter">(&(objectClass=group)(cn=?))</Property>
<Property name="GroupNameListFilter">(objectcategory=group)</Property>
<Property name="MembershipAttribute">member</Property>
<Property name="MemberOfAttribute">memberOf</Property>
<Property name="BackLinksEnabled">true</Property>
<Property name="Referral">follow</Property>
<Property name="UsernameJavaRegEx">[a-zA-Z0-9._\-|//]{3,30}$</Property>
<Property name="UsernameJavaScriptRegEx">^[\S]{3,30}$</Property>
<Property name="UsernameJavaRegExViolationErrorMsg">Username pattern policy violated</Property>
<Property name="PasswordJavaRegEx">^[\S]{5,30}$</Property>
<Property name="PasswordJavaScriptRegEx">^[\S]{5,30}$</Property>
<Property name="PasswordJavaRegExViolationErrorMsg">Password length should be within 5 to 30 characters</Property>
<Property name="RolenameJavaRegEx">[a-zA-Z0-9._\-|//]{3,30}$</Property>
<Property name="RolenameJavaScriptRegEx">^[\S]{3,30}$</Property>
<Property name="SCIMEnabled">false</Property>
<Property name="IsBulkImportSupported">true</Property>
<Property name="EmptyRolesAllowed">true</Property>
<Property name="PasswordHashMethod">PLAIN_TEXT</Property>
<Property name="MultiAttributeSeparator">,</Property>
<Property name="isADLDSRole">false</Property>
<Property name="userAccountControl">512</Property>
<Property name="MaxUserNameListLength">100</Property>
<Property name="MaxRoleNameListLength">100</Property>
<Property name="MembershipAttributeRange">1500</Property>
<Property name="kdcEnabled">false</Property>
<Property name="defaultRealmName">WSO2.ORG</Property>
<Property name="UserRolesCacheEnabled">true</Property>
<Property name="ConnectionPoolingEnabled">false</Property>
<Property name="LDAPConnectionTimeout">5000</Property>
<Property name="ReadTimeout"/>
<Property name="RetryAttempts"/>
</UserStoreManager>
<AuthorizationManager class="org.wso2.carbon.user.core.authorization.JDBCAuthorizationManager">
<Property name="AdminRoleManagementPermissions">/permission</Property>
<Property name="AuthorizationCacheEnabled">true</Property>
<Property name="GetAllRolesOfUserEnabled">true</Property>
</AuthorizationManager>
</Realm>
</UserManager>
To the administrative console only admins (members of the admin group) are allowed to log in.
If you want any user to log in, you may try to find role Internal/everyone and add a permission Login to the role.
However the users by default will be able only to change their password (even that's not true until you use ldaps connection instead of ldap)

Atom: autocompletion with Qt Creator UI files in Python

I'm using PyQt5 with QtCreator to generate interface .ui files. I follow a naming convention so no difficulty finding the widgets/elements of the generated interface.
Unfortunately Atom is not able to figure out the types no autocompletion or offering of available methods. I've looked around some of the Python autocompletion packages but found nothing yet.
I could generate proper Python modules using the 'pyuic' tool but prefer not to if possible.
Does anyone know a way around this?
One way to do it is simply to translate the .ui into .py every time you run your application. Then you can dynamically develop and debug your application, until it's ready for final packaging. I don't know how much startup time this adds, but certainly less than the time wasted going through documentation rather than autocomplete.
In your root directory, you have your mainwindow.ui, e.g.
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QPushButton" name="button1">
<property name="geometry">
<rect>
<x>60</x>
<y>20</y>
<width>113</width>
<height>32</height>
</rect>
</property>
<property name="text">
<string>button1</string>
</property>
</widget>
<widget class="QPushButton" name="button2">
<property name="geometry">
<rect>
<x>200</x>
<y>20</y>
<width>113</width>
<height>32</height>
</rect>
</property>
<property name="text">
<string>button2</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionOpen"/>
</widget>
<addaction name="menuFile"/>
</widget>
<action name="actionOpen">
<property name="text">
<string>Open</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
And now you can edit it as much as you want, using Qt Creator, and then run pyuic every time your interface launches.
import sys
import os
os.system("pyuic5 mainwindow.ui > mainwindow.py") # Converts the ui to py on every launch
from PyQt5.QtWidgets import *
from mainwindow import Ui_MainWindow
class App(QMainWindow):
def __init__(self):
super(App, self).__init__()
self.ui = Ui_MainWindow() # Run these two lines to integrate
self.ui.setupUi(self) # the .ui into your python setup
# Connect everything as usual, with autocomplete
self.ui.button1.clicked.connect(self.button1_click)
self.ui.button2.clicked.connect(self.button2_click)
self.show()
def button1_click(self):
print("Button 1 clicked")
def button2_click(self):
print("Button 2 clicked")
if __name__ == '__main__':
app = QApplication(sys.argv)
window = App()
sys.exit(app.exec_())

WSO2 API Manager fails when using external ldap

I am setting up wso2 API manager to use an external LDAP so it connects to my company's user base for logins but I am getting the following error which I can't find the reason:
2016-09-09 10:44:32,436 [-] [Start Level Event Dispatcher] ERROR Activator Cannot start User Manager Core bundle
java.lang.NullPointerException
at org.wso2.carbon.user.core.config.RealmConfigXMLProcessor.buildRealmConfiguration(RealmConfigXMLProcessor.java:367)
at org.wso2.carbon.user.core.config.RealmConfigXMLProcessor.buildRealmConfiguration(RealmConfigXMLProcessor.java:281)
at org.wso2.carbon.user.core.common.DefaultRealmService.buildBootStrapRealmConfig(DefaultRealmService.java:136)
at org.wso2.carbon.user.core.common.DefaultRealmService.<init>(DefaultRealmService.java:84)
at org.wso2.carbon.user.core.common.DefaultRealmService.<init>(DefaultRealmService.java:113)
at org.wso2.carbon.user.core.internal.Activator.startDeploy(Activator.java:68)
at org.wso2.carbon.user.core.internal.BundleCheckActivator.start(BundleCheckActivator.java:61)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Here is my user-mgt.xml:
<UserManager>
<Realm>
<Configuration>
<AddAdmin>false</AddAdmin>
<AdminRole>admin</AdminRole>
<AdminUser>
<UserName>procergs-felipe-schnack</UserName>
<!-- Password>admin</Password -->
</AdminUser>
<EveryOneRoleName>everyone</EveryOneRoleName> <!-- By default users in this role sees the registry root -->
<Property name="isCascadeDeleteEnabled">true</Property>
<Property name="dataSource">jdbc/WSO2CarbonDB</Property>
</Configuration>
<UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadOnlyLDAPUserStoreManager">
<Property name="TenantManager">org.wso2.carbon.user.core.tenant.CommonHybridLDAPTenantManager</Property>
<Property name="ReadOnly">true</Property>
<Property name="ConnectionURL">ldap://ldap1.procergs.reders:389</Property>
<Property name="ConnectionName">uid=wso2,ou=U4S,ou=PROCERGS,o=estado,c=br</Property>
<Property name="ConnectionPassword">xxxx</Property>
<Property name="UserSearchBase">ou=procergs,o=Estado,c=BR</Property>
<Property name="UserNameAttribute">uid</Property>
<Property name="UserNameSearchFilter">uid=?</Property>
<Property name="UserNameListFilter">(objectClass=posixAccount)</Property>
<Property name="DisplayNameAttribute">displayname</Property>
<Property name="ReadGroups">false</Property>
<Property name="GroupSearchBase">ou=system</Property>
<Property name="GroupNameAttribute">cn</Property>
<Property name="GroupNameSearchFilter">(&(objectClass=groupOfNames)(cn=?))</Property>
<Property name="GroupNameListFilter">(objectClass=groupOfNames)</Property>
<Property name="MembershipAttribute">member</Property>
<Property name="BackLinksEnabled">false</Property>
<Property name="UsernameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
<Property name="PasswordJavaRegEx">^[\S]{5,30}$</Property>
<Property name="RolenameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
<Property name="SCIMEnabled">false</Property>
<Property name="PasswordHashMethod">PLAIN_TEXT</Property>
<Property name="MultiAttributeSeparator">,</Property>
<Property name="MaxUserNameListLength">100</Property>
<Property name="MaxRoleNameListLength">100</Property>
<Property name="UserRolesCacheEnabled">true</Property>
<Property name="ConnectionPoolingEnabled">true</Property>
<Property name="LDAPConnectionTimeout">5000</Property>
<Property name="ReadTimeout"/>
<Property name="RetryAttempts"/>
<Property name="ReplaceEscapeCharactersAtUserLogin">true</Property>
<Property name="defaultRealmName">WSO2.ORG</Property>
</UserStoreManager>
<AuthorizationManager class="org.wso2.carbon.user.core.authorization.JDBCAuthorizationManager">
<Property name="AdminRoleManagementPermissions">/permission</Property>
<Property name="AuthorizationCacheEnabled">true</Property>
<Property name="GetAllRolesOfUserEnabled">false</Property>
</AuthorizationManager>
</Realm>
</UserManager>
What I am missing? I tried to lookup the source code in wso2 SVN repo but I am still lost.
Thanks!
Actually you need to point to a existing user in your LDAP to be the super user of the system. The super user is a special user in the system which has all the permissions to manage the system. Hence this configuration is required. You can use Ciper tool to encrypt your password and store it. You can refer this.

Starting an Extension in Alfresco 4.0

I want to run the extension
("C:\Alfresco\tomcat\shared\classes\alfresco\extension\scheduled-action-services-context.xml)
I have made some changes in it, however when I restart the server I don't see it in my log files.
Do I need something else to start it.
EDIT:
Here is the content of my scheduled action services:
<!--
Define the model factory used to generate object models suitable for use with freemarker templates.
-->
<bean id="templateActionModelFactory" class="org.alfresco.repo.action.scheduled.FreeMarkerWithLuceneExtensionsModelFactory">
<property name="serviceRegistry">
<ref bean="ServiceRegistry"/>
</property>
</bean>
<!--
Execute the script /Company Home/Record Management/testscript.js
-->
<bean id="runScriptAction" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">
<property name="actionName">
<value>script</value>
</property>
<property name="parameterTemplates">
<map>
<entry>
<key>
<value>script-ref</value>
</key>
<!-- Note that as of Alfresco 4.0, due to a Spring upgrade, the FreeMarker ${foo} entries must be escaped -->
<value>\$\{selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home/app:dictionary/app:scripts/cm:send_mail.js"' )\}</value>
</entry>
</map>
</property>
<property name="templateActionModelFactory">
<ref bean="templateActionModelFactory"/>
</property>
<property name="dictionaryService">
<ref bean="DictionaryService"/>
</property>
<property name="actionService">
<ref bean="ActionService"/>
</property>
<property name="templateService">
<ref bean="TemplateService"/>
</property>
</bean>
<!--
Run the script every minute - select the single node company home that is not used ...
-->
UNTIL_FIRST_FAILURE
IGNORE
lucene
workspace://SpacesStore
+#ia\:fromDate:\$\{luceneDateRange(now, \"P10D\")\} AND +PATH:"/app:company_home/st:sites/cm:prova/cm:calendar//*"</value>-->
+PATH:"/app:company_home/st:sites/cm:valdel/cm:calendar//*" AND +#ia\:fromDate:[NOW TO MAX]
</property>
<property name="cronExpression">
<value>0 * 8 * * ?</value>
</property>
<property name="jobName">
<value>jobD</value>
</property>
<property name="jobGroup">
<value>jobGroup</value>
</property>
<property name="triggerName">
<value>triggerD</value>
</property>
<property name="triggerGroup">
<value>triggerGroup</value>
</property>
<property name="scheduler">
<ref bean="schedulerFactory"/>
</property>
<property name="actionService">
<ref bean="ActionService"/>
</property>
<property name="templateActionModelFactory">
<ref bean="templateActionModelFactory"/>
</property>
<property name="templateActionDefinition">
<ref bean="runScriptAction"/> <!-- This is name of the action (bean) that gets run -->
</property>
<property name="transactionService">
<ref bean="TransactionService"/>
</property>
<property name="runAsUser">
<value>System</value>
</property>
</bean>
AND WHEN I CHECK THE STDOUT, I'M SEEEING THIS ERROR:
2012-03-30 11:00:00,230 ERROR [freemarker.runtime] [DefaultScheduler_Worker-8] Template processing error: "No nodes selected"
No nodes selected
The problematic instruction:
==> ${selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home/app:dictionary/app:scripts/cm:send_mail.js"' )} [on line 1, column 1 in string://fixed]
Java backtrace for programmers:
freemarker.template.TemplateModelException: No nodes selected
at org.alfresco.repo.action.scheduled.FreeMarkerWithLuceneExtensionsModelFactory$QueryForSingleNodeFunction.exec(FreeMarkerWithLuceneExtensionsModelFactory.java:180)
Could someone explain me this.. I have written a cron to run every 8 minutes but its not working
"Run the extension" doesn't really make sense. When you start Tomcat, the Alfresco web application will load that Spring configuration file automatically because it is on the classpath (assuming you have set up your shared classloader correctly) and it ends in "context.xml". If you aren't seeing something you expect in the log files, check log4j.properties to make sure you have a logger set. If all else fails, use a remote debugger like Eclipse and set a breakpoint in one of the Java classes referred to by your context file.
Maybe your error is because of https://issues.alfresco.com/jira/browse/ALF-9981

Resources