PyQt Hide QDialogs Inside of QTreeWidget - python

I have a QTreeWidget with QComboBoxes inside of it. I would like to be able to hide the combo boxes.
I am getting the QComboBox out of the tree using the itemWidget function. I have tried using setVisible(False) and hide() but neither work. Can anyone explain why this is the case and possibly offer a soultion?
I suspect it has something to do with the QTreeWidget or the QTreeWidgetItems controlling the visibility of its widgets.

Have you tried putting the QComboBoxes inside a layout inside a QWidget, and placing the QWidget in the QTreeWidget?

Related

Why the widget btn1 in the subpage of QStackedWidget can only define signals for QStackedWidget, but not for page: deviceTypeSelect in QStackedWidget?

I want to use btn1 to send a signal to the slot function of deviceTypeSelect, but btn1 can only be associated with QStackedWidget.
There are two problems.
The first is conceptual: Designer cannot know anything about custom slots that are going to be implemented in a promoted widget, and it even should not. The connection to those slots can only be achieved programmatically, and that's for good reasons: Designer cannot "inspect" (nor it should) the source of the files that will be promoted, and it's also completely possible that one would promote a widget and use different classes with the same design files.
The other problem is technical: the "pages" of multipage widgets like QStackedWidget or QTabWidget cannot be used as signal targets on Designer. I don't know if it's just a missing feature or it's by design (knowing how multipage widget plugins are dealt with I wouldn't bet about the it), but unfortunately it really is not possible.
If you want to connect to standard QWidget slots (setEnabled() etc.), set a dummy boxed layout on the page, and add another QWidget in it, but if you use custom slots, as explained before, those must be manually connected from your code.

How make a custom QPushButton in PyQt5?

I need to add a big button which will start some process. I know that I can make QPushButton large enough, however, I wish it be something like that
What can you suggest?
use flat QPushButton with transparent icon.

How would I go about making a overlay widget

How would I go about making a overlay widget with qt?
I've considered using a QPaintEvent or a QGraphicsScene, but I want to be able to add widgets and for the widget to not occupy space in a layout, causing other widgets to shift when the popup appears.
I believe the best solution is to parent the so called overlay widget to the window or even have the overlay widget be in its own window.
The first solution might be easier to do, but the overlay widget is bound to the inside of the window.
If you go with the second solution, you will have to play with the windows flags to make it borderless.
In both cases, you may have to use the raise() function to make sure your overlay widget is on top.
Discussing "using a QPaintEvent or a QGraphicsScene" is off-topic. How you draw the widget does not impact how the widget will interact with the widget stack.
If you want an example, you can take a look at the code of QCompleter which does something similar. In particular look for QCompleter::setPopup() and QCompleterPrivate::showPopup().

Pyqt Hide/Remove QAction Menu from toolbutton

self.find_next_ret_act = QtWidgets.QAction(triggered=self.toolButton_5.animateClick)
self.find_next_ret_act.setShortcut(QtGui.QKeySequence("Return"))
self.find_next_enter_act = QtWidgets.QAction(triggered=self.toolButton_5.animateClick)
self.find_next_enter_act.setShortcut(QtGui.QKeySequence("Enter"))
self.toolButton_5.addActions([self.find_next_ret_act, self.find_next_enter_act])
I am using PyQt5 and I was trying to set couple of shortcuts to one tool button but it didn't work except with the QAction workaround but the problem now is that I want to hide the QAction menu that appears when I hold the tool button down, is there any way to do so?
Thanks,
Max

PyQt: How to expand all children in a QTreeWidget

There is no real problem, I have just a cosmetic problem. Well, first I create a form with Qt Designer. On this form I place a QTreeWidget. We are still in Qt Designer. In QTreeWidget, I make a few entries (parents), and then I also take a few child entries. When I am done, I save the ui-file and then I load this file - using loadUi() dynamically. In this case I use PyQt4. Up to this point no problem.
When I load the form with placed QTreeWidget I want the program to expand all child entries. By default, when I run the program I only see the parent entries. When I want to see the child entries I have to click on the parent entries, but I don't want this.
Is there a way to solve this?
There is an expandAll() method, which QTreeWidget inherits from the QTreeView class. So, after calling loadUi(), just add something like this:
self.treewWidget.expandAll()

Categories