I am new to QtDesigner - in the main window when I am adding widgets, I can't add any more widgets off-screen (i.e where scrolling down would normally allow me to access and view). There is probably a very simple answer to this but I can't find it anywhere. Is the main window a fixed size that will not allow widgets to be added outside of the dimensions of the full screen?
Thanks
Related
So I have a script running inside another program (The Foundry's Hiero) and I'm just making a new QWidget object, and calling self.show()
Now, I can set it to self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint), so my window will stay on top of the main window, even if you click on something in the main window.
The problem is, this is a sort of popup window that you configure settings in, and it triggers other QWidget popups. If I set my window to WindowStaysOnTopHint, those subdialogs that my widget triggers end up beneath my widget.
Is there a way in PySide/PyQt to make a window stay on top/keep focus from the main application window in particular, but not everything?
You can use the QApplication.focusChanged signal to raise your widget up when Hiero's main window is selected. Then you would just need to remove the WindowStaysOnTopHint flag.
I'm not familiar with Hiero's API, but I'm guessing you could try something like:
def raiseMyWidget(old, new):
if new == hiero.ui.mainWindow():
myWidget.raise_()
QtWidgets.QApplication.instance().focusChanged.connect(raiseMyWidget)
Hope this helps! You can take advantage of the old parameter or some other means to make sure that your widget isn't raised above the others as well.
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().
I have an QMdiSubWindow which contains a couple of widgets. One of these widgets is a QWidget with a QGridLayout() which can contain an arbitrary number of sub-widgets which is determined at runtime (initially none). I can't seem to workout how to get the MDISubWindow to automatically resize when the number of sub-widgets in the grid layout changes. Should I be re-implementing the sizeHint() somewhere? ie in the main widget or the sub-widgets?
The QMdiSubWindow resizes fine when I drag the resize handle with the mouse and snaps to show the correct size.
I've tried calling .resize() and .updateGeometry() on both the widget and the QMdiSubWindow but It doesn't obviously work. Any clues would be much appreciated.
#ekhumoro suggested I try adjustSize(), which didn't work initially. I did some more searching and ended up with the following solution which worked for me
QTimer.singleShot(1, self.parent.windows[self.uuid].adjustSize)
where
self.parent.windows[self.uuid]
is the QMdiSubWindow object. I'm guessing that just calling self.adjustSize() doesn't work because the sizeHint is not updated until the later in the event queue.
I'm writing a PySide application with a GUI meant for a touch screen. It has a main window that covers 75% of the screen and a 25% vertical panel that has buttons that control the content displayed on the main window (several widgets/screens should appear on the main window).
I've seen several different ways for doing this "split": QFrame, QStackedLayout, QStackedWidget. Being a beginner with PySide/Qt, I couldn't figure out which one is the best way to go for my specific case. Any suggestions or example applications?
QFrame with a QVBoxLayout and specify the stretch factor: (C++ code)
MainWidget main = new MainWidget();
ButtonWidget buttons = new ButtonWidget();
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(buttons);
layout->addWidget(main);
layout->setStretch(0,25);
layout->setStretch(1,75);
form->setLayout(layout);
I am working on Qtdesigner for generating a GUI for my python app.
The problem is that I had manually made the widgets and then compiled it to py. But then I found out that the components did not resize when maximised.
So I opened the .ui file in designer and selected the group box for my widgets and chose layout in grid by right clicking on it.
Even now the widgets do not resize on maximising....
Do I have to do something else ???
Thanks a lot...
To have the widgets resized with the window, you must apply a layout to your top-level object (usually QMainWindow), and then place your new widgets where you want in the layout (and maybe other layouts for a more complicated window).
NOTE: the menu items allowing to apply a layout on the main window will be available only once you have placed your first widget in it.