kandi X-RAY | Qt Summary
kandi X-RAY | Qt Summary
Qt development knowledge and experience summary. Including Qss, database, Excel, Model/View, etc.
Top functions reviewed by kandi - BETA
Qt Key Features
Qt Examples and Code Snippets
Trending Discussions on Qt
I am trying to use
beginMoveColumns to move a single column over in a
QTableView, but it doesn't work properly in my example below. The cell selections get shuffled and column widths don't move. Moving rows using the same logic seems to work correctly. What am I doing wrong?
ANSWERAnswered 2021-Jun-15 at 20:13
Turns out it was a bug, I made a bug report here: https://bugreports.qt.io/browse/QTBUG-94503
As a workaround I just clear cell selection on column move, and use this snippet to move column widths
A part of my form contains
Status Box) with 4 child
QGroupBoxes arranged in a grid layout (2x2). Two bottom
Widget 1 Box and
Widget 2 Box) contain widgets of fixed size (with set
maximumSize) so they're non-resizable at all in both directions. Because of that rigid size constraints top row of
Summary Box and
Helper Box) can only be resized in vertical direction.
And here comes the troublesome part. Top-left
Summary Box) have grid layout 5x3 while top-right (
Helper Box) have vertical layout with 6 rows. If I have naive widget placement as shown on picture 1 Qt is enlarging vertical size of both labels in top row to make height of both
QGroupBoxes equal (see red arrows on picture 1).
This is definitely that I don't want so I've added vertical spacer to the bottom of
Summary Box and from the first glance it worked (picture 2). But only from the first glance... What you see is the minimum height of my whole form and the bottom side of spacer and last
QCheckBox in the
Helper Box seems to be aligned.
If I'm expanding my form vertically this spacer grows a bit and that causes the increase of height of both top
QGroupBoxes. As a result spacing between
QCheckBoxes increases too and we can also see that top and bottom spacing are unequal for the top-right box (see red arrows on picture 3).
I've tried to play with
sizeType for my vertical spacer. If I set it to
MinimumExpanding then the spacer doesn't grow on resize (and doesn't shrink, too) but it appears to be expanded to the size as on picture 3 (corrupting spacings between
QCheckBoxes too). If I set it to
Expanding then I observe the same behavior as described above for picture 3.
What is the proper way to achieve alignment for two
QGroupBoxes in a row of grid without affecting spacing between elements (e. g. in that case make vertical spacer to fit only single row of grid layout and never expand/shrink)?
ANSWERAnswered 2021-Jun-15 at 17:18
I've started to create UI tests for my PyQt5 widgets using QtTest but have run into the following difficulties:
In order to speed up things, some of my widgets only perform operations when visible. As it seems that QtTest runs with invisible widgets, the corresponding tests fail.
For the same reason, I cannot test program logic that makes a subwidget visible under certain conditions.
Is there a way to make widgets visible during test? Is this good practice (e.g. w.r.t. CI test on GitHub) and is QtTest the way to go?
Below you find a MWE consisting of a widget
mwe_qt_widget.MyWidget with a combobox, a pushbutton and a label that gets updated by the other two subwidgets:
ANSWERAnswered 2021-Jun-15 at 17:01
The problem is simple: QWidgets are hidden by default so isVisible() will return false, the solution is to invoke the show() method in init() to make it visible:
How to get the return value? Attach my code. My intention: Want to check the QListWidget and if it's empty, a message Box popup will raise and ask the option from the user. Problem: At the stage of beginning itself, a Message box popup will display, (I don't want it at the beginning stage), If the QListwidget is empty then the MessageBox popup will display as desired, and if we select "Yes" or " No" Button, Nothing will return/print in the first file. How to resolve?
ANSWERAnswered 2021-Jun-15 at 16:49
In first it is not necessary to make the verification be done in a new class, it is also logical that you invoke func_create_newitem since as you point out that method must be invoked when the item was not found.
I'm trying to figure out how to create a timeout for the handshake process in a TLS connection in a
I tried something like this in the overriden
ANSWERAnswered 2021-Jun-15 at 10:02
I ended implementing the TLS handshake timeout this way:
I am implementing a function which searchs a
QModelIndex based on a
However if I cannot find this index, the function should retun an invalid index.
My model is a
Is is okay to return
invisibleRootItem()->index() as an invalid index?
In the qt documentation is noted that it will always creates an invalid index.
ANSWERAnswered 2021-Jun-15 at 07:36
I have a python code that I can add multiple rectangles on a QGraphicsScene....
ANSWERAnswered 2021-Jun-14 at 18:46
There are several options:
So I have a Qt StyleSheet called
main.qss in the style sheet I am trying to set width and height it doesn't work it just remains the same. This same thing happens for Margins aswell.
Here is the QSS:...
ANSWERAnswered 2021-Jun-14 at 17:07
Your stylesheet doesn't work for two reasons:
height) properties generally don't apply to widgets, but only to subcontrols, as explained in the docs:
Warning: Unless otherwise specified, this property has no effect when set on widgets. If you want a widget with a fixed width, set the min-width and max-width to the same value.
- the "dot" separator doesn't work as it does in python, but as it does in css: it's a class selector:
.QPushButtonMatches instances of QPushButton, but not of its subclasses.
If you want to match the
objectName property, you need the ID selector:
What my code is about: I'm currently working on a project to create an image browser for all the images I have in my PC. I have created a database of all the images, this app will give me the ability to search through the database to find, and view and cycle through the images.
What my problem is: I'm trying to read left and right arrow key presses and connect them to a function that will change the shown image to the previous or next image in sequence. But for some reason the first two left-arrow presses don't register and none of the right-arrow presses register. Also, no other key presses are registering. My guess is that this is happening because the arrow keys are cycling through the widgets on screen. Need ideas on how I can fix this....
ANSWERAnswered 2021-Jun-14 at 17:19
The main problem is that you're adding widgets that can get focus, while the "viewer" doesn't have a focus, nor it can accept one by keyboard/mouse if not programmatically.
The result is that when the window is shown the first time, Qt will try to set the focus on the widget that can accept one within the central widget, but since there's none, any keyboard event is ignored. Whenever you try to use the arrow keys, then, Qt will use the "keyboard navigation" mode, and will find the first widget that can accept focus (the "search" button, if you go left), making the event accepted, and thus not propagated to the main window; going further, if you go left once more, the "tags" combo will get focused, again accepted and not propagated.
A temporary workaround could be to ensure that the buttons and line edit only get focus by clicking (but buttons should probably not get focus at all):
I would like to have folder with tiles
realTiles in folder with .exe.
Of course I can add folder to qrc and everything is ok:...
ANSWERAnswered 2021-Jun-14 at 12:04
Try to give the full path
No vulnerabilities reported
Reuse Trending Solutions
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page