QToolBar: Is there a way to add QAction to a QToolBar in QtDesigner? - pyqt4

I've a PyQt4 Installed on Python 2.6. I wish to insert actions or widgets into a toolbar in QtDesigner instead of adding them in code, with addAction or addWidget (as simple as adding actions to a menu in design time).

You can add actions by dragging them to your tool bar from the "Action editor" dock window. You cannot add widgets to the tool bar in Qt Designer, I'm afraid you'll have to do this from your code.

You can create your own widget plugins with new or extended functionalities.
Just follow the definition rules from the documentation .
I use a lot of custom widgets inside the Qt Designer.
Once you have figured out, how it works, it becomes a really power full method for your design work flow inside Qt Designer.

Related

How to use built in designer widget Icons for subclassed widgets in pyqt5

I've built lots of custom widgets to be used in Qt Designer, lots are just sub-classed standard widgets and I would like to use the standard icon. I can't find any reference to them nor could I actually find them on my system. If you leave out the icon function in the designer custom widget plugin, it will use a generic QT icon but that's it.

Where do i get more widgets for qtcreator?

In qtcreator, when i highlight the qml file, i can select the design tab. How do i add more qt widgets to it?
I've installed qml-module-qtquick-controls from the repos and any qml-module-* named packages that i can, but in the qml types of qtcreator, no extra qml types appear in the pane. I was looking for widgets like buttons, etc but nothing seems to work
What should i install from the repo to get buttons that i can drag and drop into the form editor? I base this on having seen pictures of others having a paneful of widgets. On the other hand when i click on a *.ui file, the design tab reveals a different editor with all kinds of widgets. What is the difference between a *.qml file and a *.ui file?
first question : "getting more controls in QML file"
when you are in Design mode you have three tabs on top:
QML Types, Resources and Imports.
The last one is what you need. Click on the button with "Add Import" and a list with all possible qml imports is shown.
fi. choosing QtQuick.Controls 2.13 will add buttons, check boxes, radio buttons and others...which you will see now on tab "QML Types"
second question:"What is the difference between a *.qml file and a *.ui file?"
qml files are meant to be used in Qt Quick applications and ui. files for Widget based applications. You will find the basic introduction to them in the Qt Creator manual topic "Designing User Interfaces"

Menu Button that does not dismiss options onclick in JavaFX 2

I am quite new in JavaFX and I have a question about the design. I am creating my main menu in FXML using Scene Builder. I have various menu buttons and each of these have a sub-menu. These sub-menu options will open new windows. Is it possible to declare these submenu choices so they do not dissapear after I click on them? If so, can I declare it in my fxml or I have to do it programatically?
Also, is it possible to detach it from the menu button? I would like to have my menu choices around 1 cm away from the menu button itself.
Thank you
Suggested Alternate Solution
If you want more flexibility in positioning a popup menu after a button click as well as fine control over when the menu shows and hides, try using a Button + a ContextMenu rather than a MenuButton.
The relevant methods are:
contextMenu.show(anchorNode, side, dx, dy)
contextMenu.hide()
There is sample code for triggering a context menu on a button press button in the ContextMenu javadoc.
You might also need to monitor the context menu's showingProperty and in a listener show the menu again if the JavaFX system has decided to try and hide it after some user action and you still want the menu visible.
Answers to additional unrelated comments
OK It sounds logical, yet since Im not really good in JavaFX yet, your Idea is quite challenging.
It's not that hard to implement, but from your subsequent comments it sounds like it's probably not the user interface you want for your users anyway (which makes sense to me because the interface you describe in your question seems a little strange).
I thought If it would be easier to have a static xml that have various menu choices, lets say aligned to the right and then whenever I click one of the choices, a new FXML would be loaded in the middle of the screen holding buttons for a submenu?
That seems logical. Sounds like a JavaFX version of a traditional web page layout with a navigation menu on the side controlling a content pane in the center.
A Java only version of that is: How to have menus in java desktop application. You could adapt that to a FXML based version without too much difficulty.
You might also be interested in Managing Multiple Screens in JavaFX.
Also, any tutorial for beginners would be greatly appreciated. These Oracle ones dont make too much sense for me
If you are beginning JavaFX, I recommend using just the Java API portions of JavaFX until you become familiar with them, and then use FXML only after you are comfortable with the Java API.
Personally, I think the Oracle JavaFX Tutorials are excellent. The difficulty for beginners is that the tutorials are also part reference material, which complicates portions of them (especially the deployment related pieces).
If you prefer a different tutorial style see:
Makery JavaFX tutorial (good for beginners)
zenjava tutorials (more advanced)

how to add a custom mfc control to the dialog window?

I've derived a class from CStatic in MFC. But I don't know how to add it to my dialog window.
This mfc application that I'm working on is a dialog based application.
In Gtk+ or Qt we could use layouts and add our widgets to them, but in mfc it doesn't seem to be such a mechanism. I'm wondering how is it possible for an custom made control to be added to another GUI element!!!
Please give me a simple example if you can.
thank you
I think the technique you are looking for is subclassing (MSDN).
There is a good sample on that page too.

slightly customized widget for PyQt4 with qtdesigner

I am creating an application with PyQt4 and I want to use qtDesigner to design the layout. The application contains a QGraphicView, for which I want to implement panning and zomming per mouse. The only way I know how to do that is deriving from QGraphicView overwriting the "mouse*" functions to do the panning and zooming.
Now I want to use this new custom widget with qtdesigner.
googling I find that I could write a "custom widget plugin" for qtdesigner. While it does not seem to be to difficult, I still find it overkill for such a little adjustment I want to make.
What other ways are there to customize a widget in PyQt4 when the layout is done with qdesigner?
Thanks!
You can promote your QGraphicsView to your own subclass
In the designer, right click on the QGraphicsView and select "Promote To" and fill the dialog with relevant information about your own subclass:

Resources