I have a QMainWindow that creates a QListWidget and a QTreeViewWidget and places them in a QDockWidget. I then have an "open" action in the menu bar. When clicked it gives a dialog were you choose a pickle file to load. Upon opening i need the information to be loaded into the QTreeView and QListWidget in the QMainWindow. However, since the widgets were already instantiated upon opening the program they don't update. Everything works fine if i choose a file before the program actually starts. Everything also works if i close and reopen the widgets after i choose my file. So, is there some way to update the QMainWindow to show the updated information after opening a new file?
Related
Trying to use python to programmatically save a PyQt5 QWidget as an image (any format)
Came across a solution here, but this solution more or less saves a screenshot of the widget window, which demands the widget window to be open in the first place
What I'm trying to do is to get the widget to be saved without the GUI window being generated/shown on screen
So to be more precise:
Widget is created with script
Created widget is automatically saved without the UI popping up or external interactions
The widget I'm working with can be found here
in my pyqt5 application, I have a QLineEdit that can have its value changed by both typing and pressing buttons that have advanced actions on the QLineEdit's text.
I have done some research and found the setFocusPolicy, but it does not have a permanent focus option, is there a way around this?
edit: by "permanent focus" I mean that the QLineEdit is always in a focus state where one can type into it, but clicking somewhere else or tabbing does not change the focus to a different widget
musicamante had it right, what I did was add a corresponding *widgetObject*.setFocusPolicy(Qt.NoFocus) line for each of my widgets that could possibly focus
note: I had this import line specifically for the NoFocus constant
from PyQt5.QtCore import Qt
I have designed a QDialog form on which have placed different widgets to do some calculations.
However, everything is working according to plans.
Except that I want to disable all widgets except one for initial input.
I want widgets to follow tab order. After being done entering data, it should trigger or enable the next button to the end.
Previous widgets should loose focus and become disabled as soon as am done with them. But when I click the last button, the first widget should become active again, to allow fresh entry of data.
I used PyQt5 designer version 5.11 to design.
I know that similar question was already answered, but my case is a little bit different
Case:
I have a QWidget which contains a QLineEdit and a QListWidget
The QListWidget is a FramelessWindow which means that it is not located in the main window but it appears independently (actually it is a dynamically changing list depending on the content of the QLineEdit filed: "filter as you type")
Problems:
When I close the main window, it will not close the QListWidget automatically. After the main window closed, the QListWidget will be still seen. - I could not find event, in the QWidget, which would work for that purpose. The closeEvent(self, event) is never triggered.
When I move the main window the QListWidget will be still stay in the original position. It will not follow the QLineEdit's position. I could not find event, in the QWidget, which would work for that purpose.
Conditions:
I do not want to detect the changes in the main window. I know that the
closeEvent(self, event)
works in the main window, and I could delegate it to the QListWidget.
BUT I want to write an independent widget, which does not depend on the setting in the main window.
Can somebody help me with telling/suggesting how to detect the window close/window move inside a widget?
If you need the code (pretty long ~300 lines), I can copy it here.
PyQt noob here.
I need to call a dialog window as soon as the main window is loaded.
I also need the main window to be displayed in the background when this dialog is shown on top of it.
So, I'm looking for a 'onload' sort of a signal for the main window to call the function which in turn calls the dialog. Is there any other way around?
You can override the QWidget.showEvent for your QMainWindow to achieve the same effect. However, you need to keep track of whether it is the first time the window is shown or not since that method will be called every time the window is displayed after being hidden. Then use a modal QDialog so that the main window is shown in the background, but not enabled.