QTreeWidget created at runtime failed to emit itemDoubleClicked signal - pyqt

I made a widget that inherits from QTreeWidget and successfully created an instance and added it to a tab control. However, I am trying to capture the itemDoubleClicked signal, but failed. I tried to put the connect statement in either the form that has the tab control, it failed to emit signal, then I put the connect inside my custom widget, it failed also. So, not sure how to connect to a tree widget that is created at runtime.
from within my custom QTreeWidget class:
QtCore.QObject.connect(self, QtCore.SIGNAL('itemDoubleClicked(QTreeWidgetItem, int)'), self.edit_treeitem)
or from within the tab control:
QtCore.QObject.connect(self.mytree, QtCore.SIGNAL('itemDoubleClicked(QTreeWidgetItem, int)'), self.edit_treeitem)
Can anyone help?

Use the new style of signal connection:
self.mytree.itemDoubleClicked.connect(self.edit_treeitem)

Related

Xpages - Custom control getting a custom property from another custom control

I've searched google and stack but can't seem to find a definitive answer. What I would like to do, is something like this:
Say I have custom control A, within which, is a radio button, when I click it, I want it to grab a custom property that is set on custom control B, lets say compositeData.Name as an example. Can I do this?
If I give custom control B an ID, lets say ccB, can the radio button in custom control A do something like, getComponent("ccB").getValue().compositeData.Name so I can get the value of the property I passed into custom control B using the custom property 'Name'?
If its a straight no, at least I know to stop playing around with the idea! Thanks
Reaching from one control into the inside of another control would break component isolation. You might want to take a different approach:
Option a - client side:
Your control emits a JavaScript event that bubbles up until it reaches a parent element that contains the control you want to change (presumably the parent Dom element). There you set the property of that element.
Option b - server side:
As Urs suggested: bind both to a bean and handle the updates inside the bean

Kentico 9: Auto Add Binding in Custom Module

I have created a custom module (actually I have created a handful in recent years, and this same obstacle frustrates me every time) following the Kentico documentation:
https://docs.kentico.com/display/K9/Creating+custom+modules
The problem I end up with every time, is in developing the User Interface for Parent/Child classes. I create a Vertical Tab node, and beneath it I add an edit tab and a Binding tab for the child class. This all works, and I can add and remove bindings at will, but what I can't do is ADD a new child class and bind it.
Using the Standard Edit Binding template, I am able to bind EXISTING Job Titles to the selected Category, but I cannot CREATE a new one from that page:
To solve this, I created a custom Edit Binding template, and added a New Child Class Header Action that points to a New / Edit Object child:
Which gives me a button that I can use to add a new child class (Job Title):
This approach works per se, in that I can click the New Job Title button and create a new item on the subsequent page:
But no binding is created to link the child object (Job Title) to the selected parent object (Category), An even bigger problem is that once I click Save, I am presented with the following:
The new object DOES SAVE, but the post-save navigation is somehow failing. The event log offers little in the way of diagnostics:
So I thought to create a completely custom interface to accomplish my needs here, according to the Kentico documentation:
https://docs.kentico.com/display/K9/Manually+creating+the+interface+for+custom+modules
So I change the Element Content of the New Job Title page to a custom page that I created to post a DataForm for the new object:
Taking care to assign the proper Object Types on the Properties Tab:
The intent was to programmatically create the binding upon save and also handle the correct navigation to avoid the ambiguous parameter error above, but when this page loads, the UIContext.ObjectID and UIContext.ParentObjectID are both 0:
So I cannot create the binding programmatically. I was able however to solve the error that I received by manually assigning the redirect. The experience is still lacking even with this hack, since it returns to the listing page, but the user still has to click "Add Items" to assign the binding after successfully creating it with the custom page I built.
This cannot be the proper way to do this, so any help with getting me on the right track would be greatly appreciated.
In order for the EditedObject to have a value you have to either decorate the page with the EditedObjectAtribute e.g. like this:
[EditedObject("<custom.objecttype>", "<objectid>", ...)]
or set the object yourself:
int objectId = QueryHelper.GetInteger("objectid", 0);
EditedObject = SomeInfoProvider.GetSomeInfo(objectId);
In your case, I'd recommend exploring what query parameters are available on the page and using them to fetch appropriate object(s). Also, make sure "JobCategoryId" is passed to the "New Job Title" dialog so that you can create the binding.
Btw - kudos for well asked question!

Single Instance Window in Catel v4.0

If I have a button (bound to Command 'OpenOtherWindow') that opens a DataWindow by using IUIVisualizerService.Show(viewModel), how can I prevent another instance of said DataWindow to open?
I do not think that creating a Singleton ViewModel is the correct way to do it and having a boolean 'IsWindowOpen' in the ViewModel where my 'OpenOtherWindow' Command is located would not be very MVVM, although this is the current way we have done it.
How would I do it in Catel?
The key is to create a service that manages the state and instances of the windows. Then you never have to worry about the actual behavior and can change it in one place.
Then you can just call the following (pseudo) code:
_myFeatureService.Show();
In this service you can keep track if the window is already open and open the window if not. If you want to change this behavior in the future, you only have to do it in a single location: the service.

How to locate event handlers for OK and Help button in mfc?

I am new to MFC. In the project I am working on the dialogs are created in resource file(.rc).
In that there are OK button(id ID_OK) and Help button (id ID_Help). I am not able to find the event handlers for these two buttons. There are other buttons where the event handlers mapped are easily found. If someone teach me how to find those event handlers it would be very helpful.
And how can I find the functions which get called on clicking of the particular button by debugging in visual studio?
Thank you.
Double click the button (shown in rc) opened in Resource View in Visual Studio and you will be automatically placed by Studio where the Event handler is located in your code.
If this does not work, then probably delete the Button with ID's ID_OK and ID_Help in your resource view and again add it to the resource using different ID and then try to generate the event handler by double-clicking those buttons in resource view. This is because sometimes the value of ID's conflict with other ID values and hence Studio is not able to generate the Event-handler for you in that case.
Buttons don't have direct event handlers as in other frameworks (like in C#, WinForms etc). You must use message-maps in MFC.
ID_OK maps to virtual function CDialog::OnOK, you can just write your virtual function implementation. Framework will call it for you. You can also handle this message with WM_COMMAND message entry.
There is no standard resource ID as ID_Help - it is always capital, and has to be always in caps! No one is stopping you from using small letters, though - it for consistency and better readability.
Instead of fiddling with resource files (.RC and resource.h), mapping the same with your dialog class and things like that. I suggest you to go, and learn, without resource file. Start with drawing in frame (circles, filled-triangles whatever). Learn and know why virtual function are there for some messages, and message-maps for other (most) messages.
My two cents.

Saving the states of JavaFX controls on exit

I have a bunch of control objects (TextBoxes, to be precise) that get injected into my code using the #FXML annotation during the FXML load.
I would like to save the states of these controls, specifically the text values, when the user closes the Scene by clicking the close box on the title bar.
However, when I trap the CloseRequest event in an OnCloseRequest handler I find that the values of the control variables are null (the original injection works, so this is something that happens in between the loading of the FXML and the calling of OnCloseRequest).
Can anyone explain this behavior and/or suggest how I can get the functionality that I want?
TIA
onCloseRequest is
Called when there is an external request to close this Window. ...
(from Javadoc). One of the meanings of "external request" is when you close the window through OS native window close button. The closeRequest event is not triggered through the programmatic stage.close() or stage.hide() calls. So consider to handle onHiding or onHidden events.
Otherwise post your OnCloseRequest handler code.

Resources