QListWidget row size with a custom QListWidgetItem
-
You have to upload the images to an external site (e.g postimage.org).
However, with that size policy you'd get multiple inquiries about the sizes of your widget by Qt so it can calculate the correct size. If it's a fixed size, you need to set the correct policy.The
Item
class
The screen on my cel, with
sizePolicy
set toFixed
in both dimensions:
And with
setSizeHint(QSize(0, 150));
-
The
Item
class
The screen on my cel, with
sizePolicy
set toFixed
in both dimensions:
And with
setSizeHint(QSize(0, 150));
Okay, wait a bit. So you have a compound widget, does that widget have a layout? If it does you shouldn't need to do anything (even set the hint).
-
Okay, wait a bit. So you have a compound widget, does that widget have a layout? If it does you shouldn't need to do anything (even set the hint).
@kshegunov Yes, The first
TextLabel
and the text box by its side are grouped in a horizontal layout, as theText Label
and the text box below, and the wholeItem
class, sub class ofQWidget
, has a vertical layout.I wonder if the
QListWidgetItem
, or thelist
object should, somehow, have a layout defined. -
@kshegunov Yes, The first
TextLabel
and the text box by its side are grouped in a horizontal layout, as theText Label
and the text box below, and the wholeItem
class, sub class ofQWidget
, has a vertical layout.I wonder if the
QListWidgetItem
, or thelist
object should, somehow, have a layout defined.Hm that's odd. If you have a vertical layout for the widget, I'd set the policy to expanding both directions. Aside from that it might be some peculiarity of the view ... but I haven't encountered it by now.
I wonder if the QListWidgetItem, or the list object should, somehow, have a layout defined.
It has a special way of laying out the items (implemented for the view itself).
-
Hm that's odd. If you have a vertical layout for the widget, I'd set the policy to expanding both directions. Aside from that it might be some peculiarity of the view ... but I haven't encountered it by now.
I wonder if the QListWidgetItem, or the list object should, somehow, have a layout defined.
It has a special way of laying out the items (implemented for the view itself).
@kshegunov I set the
sizePolicy
toExpanding
in horizontal and vertical dimensions, but the result was the same. I tried to remove thesetSizeHint(QSize(0, 150));
,and also thesetSizeAdjustPolicy(QListWidget::AdjustToContents);
, but with the same result. -
@kshegunov I set the
sizePolicy
toExpanding
in horizontal and vertical dimensions, but the result was the same. I tried to remove thesetSizeHint(QSize(0, 150));
,and also thesetSizeAdjustPolicy(QListWidget::AdjustToContents);
, but with the same result.It's possible it may be a bug too. Can you prepare a minimal example that reproduces the behaviour? Btw, do you experience this only on the mobile device, when the screen is small?
-
It's possible it may be a bug too. Can you prepare a minimal example that reproduces the behaviour? Btw, do you experience this only on the mobile device, when the screen is small?
@kshegunov Only in the mobile. When I run on a 14" notebook display, it works as expected, i.e., the row height and width expand and reduce according to the size of the window.
I have the example ready. Where should I send it to?
In time, thanks a lot for your time!
-
@kshegunov Only in the mobile. When I run on a 14" notebook display, it works as expected, i.e., the row height and width expand and reduce according to the size of the window.
I have the example ready. Where should I send it to?
In time, thanks a lot for your time!
Upload it where it's convenient. I'd try on my machine but I don't have any device on hand, so it might be a very limited test. For now my advice is to wait a bit so our other users can see and possibly offer insight, but you may need to post it (the example and description) as a bugreport. Don't hold your breath of it being fixed though, the widgets module isn't priority ...
-
Upload it where it's convenient. I'd try on my machine but I don't have any device on hand, so it might be a very limited test. For now my advice is to wait a bit so our other users can see and possibly offer insight, but you may need to post it (the example and description) as a bugreport. Don't hold your breath of it being fixed though, the widgets module isn't priority ...
@kshegunov I uploaded the project to https://www.dropbox.com/s/tx88huu23d5cfcm/untitled6.tar.gz?dl=0. It is a tar.gz file, if you do not mind.
Well, if it is a bug, that means big trouble to me, as I am using something similar in a customer application.
Again, thanks for your help and time!
-
@kshegunov I uploaded the project to https://www.dropbox.com/s/tx88huu23d5cfcm/untitled6.tar.gz?dl=0. It is a tar.gz file, if you do not mind.
Well, if it is a bug, that means big trouble to me, as I am using something similar in a customer application.
Again, thanks for your help and time!
I took a peek at your code and I have artifacts when resizing the widget. But it's my bad. You can't do this the way you're trying to. Here:
This function should only be used to display static content in the place of a list widget item. If you want to display custom dynamic content or implement a custom editor widget, use QListView and subclass QItemDelegate instead.
So what you need to do is to rework your code to use a list view with a delegate.
-
I took a peek at your code and I have artifacts when resizing the widget. But it's my bad. You can't do this the way you're trying to. Here:
This function should only be used to display static content in the place of a list widget item. If you want to display custom dynamic content or implement a custom editor widget, use QListView and subclass QItemDelegate instead.
So what you need to do is to rework your code to use a list view with a delegate.
@kshegunov I understand... well, I'll try, once more, to understand views, models and delegates, and how Qt implement them. 8)
The examples that come with QtCreator do not, as far as I could see, show how to insert in a Q*View a custom class object, and searching the web, I could not find an example either.
Do you know any link that shows how to implement it? I would not mind to take a few days to do it from scratch on my own, but I do not have a lot of time to fix the app.
Anyway, thanks a lot!!!