Qt | Qt development knowledge and experience summary
kandi X-RAY | Qt Summary
kandi X-RAY | Qt Summary
Qt development knowledge and experience summary. Including Qss, database, Excel, Model/View, etc.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Qt
Qt Key Features
Qt Examples and Code Snippets
Community Discussions
Trending Discussions on Qt
QUESTION
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?
ANSWER
Answered 2021-Jun-15 at 20:13Turns 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
QUESTION
A part of my form contains QGroupBox
(Status Box
) with 4 child QGroupBox
es arranged in a grid layout (2x2). Two bottom QGroupBox
es (Widget 1 Box
and Widget 2 Box
) contain widgets of fixed size (with set minimumSize
and maximumSize
) so they're non-resizable at all in both directions. Because of that rigid size constraints top row of QGroupBox
es (Summary Box
and Helper Box
) can only be resized in vertical direction.
And here comes the troublesome part. Top-left QGroupBox
(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 QGroupBox
es 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 QGroupBox
es. As a result spacing between QCheckBox
es 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 Minimum
or 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 QCheckBox
es too). If I set it to Maximum
, Preferred
or Expanding
then I observe the same behavior as described above for picture 3.
What is the proper way to achieve alignment for two QGroupBox
es 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)?
ANSWER
Answered 2021-Jun-15 at 17:18Items will be aligned if both QGroupBox
es have same count of children and each row have at least one child with Expanding
vertical policy. Instead of spacer use QWidget
I removed unrelated widgets and reduces number of rows to 4 for demonstration purposes (less xml).
QUESTION
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?
I have tried to use pytest with pytest-qt without success as I couldn't find a proper introduction or tutorial and I do know "Test PyQt GUIs with QTest and unittest".
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:
ANSWER
Answered 2021-Jun-15 at 17:01The 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:
QUESTION
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?
Main
...ANSWER
Answered 2021-Jun-15 at 16:49In 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.
QUESTION
I'm trying to figure out how to create a timeout for the handshake process in a TLS connection in a QTcpServer
.
I tried something like this in the overriden incomingConnection
function:
ANSWER
Answered 2021-Jun-15 at 10:02I ended implementing the TLS handshake timeout this way:
QUESTION
I am implementing a function which searchs a QModelIndex
based on a QString
input.
However if I cannot find this index, the function should retun an invalid index.
My model is a QStandardItemModel
.
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.
ANSWER
Answered 2021-Jun-15 at 07:36You must use the default constructor of QModelIndex
(e.g. return QModelIndex()
) which is null as indicated in the docs:
QModelIndex::QModelIndex()
Creates a new empty model index. This type of model index is used to indicate that the position in the model is invalid.
(emphasis mine)
QUESTION
I have a python code that I can add multiple rectangles on a QGraphicsScene.
...ANSWER
Answered 2021-Jun-14 at 18:46There are several options:
setBackgroundBrush():
QUESTION
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:
...ANSWER
Answered 2021-Jun-14 at 17:07Your stylesheet doesn't work for two reasons:
- the
width
(andheight
) 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:
.QPushButton
Matches instances of QPushButton, but not of its subclasses.
If you want to match the objectName
property, you need the ID selector:
QUESTION
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.
...ANSWER
Answered 2021-Jun-14 at 17:19The 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):
QUESTION
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:
...ANSWER
Answered 2021-Jun-14 at 12:04Try to give the full path
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Qt
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page