For better understanding, I brought you a edited picture.
In general, is it possible to place a widget in front of another widget?
For example, on the picture above, you can see a QProgressBar placed in front of QTreeView.
Imagine a situation in which all records are loaded into QTreeView. During this process, the user should be informed how far the loading process is. I know that you can also place the QProgressBar above or below the QTreeView. But I wondered if it's also possible to place the QProgressBar in front of QTreeView?
Yeah it is possible to place a widget in front of another widget.
First of all drag a widget(Suppose a QTreeView) in a main window.
Then right click on the QTreeView and then click on Layout Alignment.
Then choose the alignment left or right and after that drag the another widget(Suppose QProgressBar) in front of your first widget.
Related
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().
The title basically says it. Right now I have the two panedWindows attached to the root window. I would like the windows to either lift() or lower() one panedWindow on top of the other when a button is pressed rather than the panedWindows being stacked on top of each other in the same window.
I also understand there may be a better way of implementing this sort of menu feature. If you know a better way, that would be great too.
I used .grid(row = 0) on both panedWindows. Then I called lift on the window I wanted to raise up and it worked.
I am trying to build a GUI which will:
Load a file with parameters which describe certain type of problem.
Based on the parameters of the file, show only certain tab in QTabwidget (of many predefined in Qt Designer .ui)
I plan to make a QTabwidget with, say 10 tabs, but only one should be visible based on the parameters loaded. Enabling certain tab is not an option since it takes to many space and the disabled tabs are grey. I do not want to see disabled tabs.
Removing tab could be an option but the index is not related to a specific tab so I have to take care of the shift in the indices. And furthermore if user loads another file with different parameters, a good tab should be added and the current one removed.
My questions are:
How to do this effectively?
Is it better to use any other type of widget?
In Qt designer, is it possible to define many widgets one over another and then just push the good one in front. If yes, how? And how to edit and change any of them?
If using RemoveTab, how to use pointers on tabs, rather than indices?
I use PyQt4
Use a QStackedWidget, which is exactly the same as a tab-widget, but without the tab-bar (which you don't need).
This widget is available in Qt Designer. The context menu has several commands for adding/removing pages and so forth. Note that the arrow buttons in the top-right corner are just there for convenience: they won't appear in your application.
Pages can be added/removed at runtime with addWidget/removeWidget:
index = self.stack.addWidget(self.page1)
self.stack.removeWidget(self.page1)
You can access the pages using either indexes or widget references.
I see that this thread is kinda old. But I hope this will still help.
You can use the remove() method to "hide" the tab. There's no way to really hide them in pyqt4. when you remove it, it's gone from the ui. But in the back end, the tab object with all your settings still exist. I'm sure you can find a way to improvise it back. Give it a try!
i was able to create a text widget with a search, and highlight every finding. The only thing i miss is a button like "Next" which jumps to the next finding.
So far i was not even able to show (jump) to the first finding.
I can move the cursor there, but i cant move the screen.
The text widget has a huge ammount of text, and i use a scrollbars if that can help.
Is there any way to move the screen or scrollbar to the curzor? Or to a tag? Or to a finding?
Thanks, Gábor
You can call the yview methods to scroll the widget by a particular amount. However, for this specific use case the text widget has the see method, which arranges for a given index to be visible.
From the official tcl/tk documentation (upon which Tkinter is built):
[see] Adjusts the view in the window so that the character given by
index is completely visible. If index is already visible then the
command does nothing. If index is a short distance out of view, the
command adjusts the view just enough to make index visible at the edge
of the window. If index is far out of view, then the command centers
index in the window.
I'm working on a PyQt program where I want to be able to have some objects, say shapes, in a 'toolbar' of sorts. I would like the user to be able to click and drag an instance of one of these shapes from the toolbar to a main canvas (a QGraphicsView).
For the toolbar I was thinking of using a QListView which I could populate using a QAbstractListModel. However, I'm not sure how I can make the QListView hold only the icons of the shapes that I want... and second of all, how I can make the object icons draggable onto my main canvas. Any ideas?
If this question contained some specific code examples with an existing direction, I could comment more specifically, but here is just some general points:
Your QListView data does not need to specifically relate to the drag and drop issue, so you can populate it however you want: QListWidget, QListView + model, ../
The important aspect is setting up drag methods on your QListX widget to set up an appropriate QMimeData in the QDrag. This is the important part that transfers the data to the drop site. You can have it send an image, or some reference to some data, for which the receiver can make use of.
Set up a drop event on the graphics view to receive and check the mime type. Lets say you are just sending an image. You can receive it and add a pixmap item to your scene. Or maybe you are sending some internal reference like an id to a dictionary. It can be looked up and the data can be added to the scene in the form you want.
Refer to the general Qt Drag and Drop docs. They are pretty much what you want.