QScrollarea with pictures not scolling - python

I want to display a film strip of pictures in my GUI. If a small number of pictures they should just show them side by side. If the amount increases it should allow scrolling to the right to reveal other pictures.
I am working inQT designer at the moment to understand the concept. Later I want to generate the code in Python "on the fly" (as pictures/widgets may be added based on user behavior). And I'm using pyqt5
I followed another Stackoverflow question's response and have set up my scroll area, the horizontal layout, and a bunch of buttons that will make the horizontal layout bigger than the scroll area. The buttons would later be replaced with pixmaps once the basic functionality is given.
I did expect this generates the scrollbar behavior but it does not. I can force to show the horizontal scrollbar to show but it does not let me scroll.
I tried to look up all the settings for the Scrollarea but nothing (obvious to me) is blocking the scroll bar behavior.
Any clues where I got it wrong?

Related

I want to add a scrollbar to the screen of my app but I'm using grid instead of pack and I don't want to use a canvas. I'm a beginner by the way

Iv'e tried a bunch of random things. I know I'm supposed to be specific when explaining this but I don't really know what to say. I made a scrollbar in a def function, it was in a whole new screen and I added it to a text box. So I'm wondering if I can just add my main scrollbar to the frame/screen in my main window. My previous scrollbar is in the recipe_steps function.

Add side panel without resizing parent

I'm using PySide2 to write a gui (witout QtDesigner).
The mainwindow contains plots and some other widgets. Through a menu option I want to open a side panel widget. The way I want it to work is that the whole window simply grows to contain that new widget without changing the size of anything else in the main window. How can this be done?
Currently the widget is just added to the central layout with addWidget, I've also tried making it a QDockWidget but it is still resized (and anyway I would like to avoid the extra fluff that comes with having a DockWidget).
So I have
---------
|content|
---------
which should turn into
-------------
|new|content|
-------------
but currently I get
---------
|new|cnt|
---------
It's hard to do well on the "client" side of Qt; this would really belong within Qt itself. I have implemented a slightly more general variant of this a couple of years ago, and just to make it work well across Windows, Mac and KDE, the code ballooned to over a thousand lines to cover all the icky corner cases, with another thousand for the test harness. It was surprisingly hard to implement the tests - especially on X11, where there was no way around using native X APIs to verify intended behavior. I got rid of that monstrosity soon later - the effort was unnecessary.
You can have the side panel as a separate top-level frameless widget that moves itself so that its top-right corner is aligned with the top-left corner of the content window, and resizes itself vertically to match the vertical size of the content window. You can of course make it slightly shorter (vertically) while still center-aligning it vertically with the content window.
You'd want to capture the resize events of the content window to do this: the side panel should install itself as an event filter for the content window.
You'll want the side panel to be a Qt child of the content window, but you also need to make it a top-level window, i.e. set the Qt::Window flag on it, so that it becomes top-level and not a sub-widget of the content window.

Resizing an icon doesn't show on GUI

I am trying to make my GUI icon go bigger.
I tried this:
MainWindow.setWindowIcon(QtGui.QIcon('Logo1.png'))
MainWindow.setIconSize(QtCore.QSize(128,128))
When 'Logo1.png' is 128x128
When I change numbers SetIconSize line, like this:
MainWindow.setIconSize(QtCore.QSize(500,500))
It doesn't show on my GUI.
My questions are:
Does this happen because I need my logo to be smaller something like 28X28?
If I need a specific size, what size is it and how do I make my logo this size?
Even if I do need a specific size, why wont setIconSize change my icon size?
The iconSize property documentation of QMainWindow explains that:
[The] size of toolbar icons in this mainwindow.
As you can see, it has nothing to do with the windowIcon.
It is up to the underlying OS and its window manager to decide the size of the icon, whether its shown in the window decoration (tipically in the title bar), the task manager/window switcher or anything else, and you don't have any control over it through Qt.
The only "exception" is when drawing client-side windows: windows for which the whole decoration is drawn by the program (the title bar with its system buttons and icon, the frame around the window, etc.).
That is, though, something that is usually discouraged as it's hard to achieve without facing various difficulties (both with drawing and interaction); it also makes the window appearance inconsistent with the whole system and could also create issues with accessibility for visually impaired people.

QTableView not resizing when resizing main window

I've got a GUI in PyQt that does the following:
The main window is a grid layout (2 columns and 3 rows). This is the scheme (soory I can't post images yet):
Now, when resizing the Main Window I'd like the QTableView widgets to be resized. However, it happens otherwise:
And the tables stay almost fixed in size (but every size-fixing property is set not to fix anything), they just expand for about 50 pĂ­xels. I've tried changing the main layout to a horizontal layout and then putting vertical layouts there but no change. I'm designing the GUI with the QtDesigner as I have no clue on how to doing it by hand-writing the code, and I need to export it to python.
What's the property determining which layout gets expanded and which one not?
I fixed it! As there were some LineEdits on the left side, they had to expand too. Setting its expanding policy to "fixed" or setting a maximum fixed it.
Thanks everybody for the help and dont worry, i'm going to learn to handwrite Qt GUIs soon.

In a GUI, how to change the mouse to Zoom-to-rectangle

I am creating a GUI that revolves around looking at a plot. The users are assumed to be very dense, as per instruction. That being said, I have been told that the default Zoom-to-rectangle button needs to have another button in the toolbar at the top of the program (which I would also program to a shortcut for ease of use).
The problem I am having is I don't know how to turn the mouse into the Zoom-to-rectangle. I don't want it to actually zoom, just change the mouse to where if it is then dragged across the plot while clicking, it will then zoom.
This is hard to explain, so if you need more information than what is provided please ask.

Categories

Resources