ListWidget Text size fixed
-
wrote on 21 Jun 2018, 05:40 last edited by amarism
Hello everyone.
I am able to insert text inside the listwidget but I am facing the problem that my text size exceeding the listwidget size. So, I want to fix the size of text equal to listwidget row size and extra text comes below the text.
I am using this code for insert text:-
QListWidgetItem* pItem = new QListWidgetItem(string);
pItem->setForeground(Qt::white); // sets white text
QT_ThumblistWidget->addItem(pItem);
Also uploading the output image:-
For the text, slider curser come. I want to fix the size of text equal to the image
-
wrote on 21 Jun 2018, 10:14 last edited by
-
wrote on 21 Jun 2018, 10:51 last edited by amarism
@Prince_0912 Both links are not useful for me. they all are discussing the font size and I am asking about the text size managing
-
@Prince_0912 Both links are not useful for me. they all are discussing the font size and I am asking about the text size managing
wrote on 21 Jun 2018, 10:57 last edited by@amarism ,
You can try like this in your code,
setSizeHint(QSize((listWidget->width()),((listWidget->height())))); -
@amarism ,
You can try like this in your code,
setSizeHint(QSize((listWidget->width()),((listWidget->height()))));wrote on 21 Jun 2018, 11:11 last edited by@Prince_0912
I don't know whether your code does what the OP wants, nor what widget you are callingsetSizeHint()
on, but it won't be right to be usingQListWidget::height()
in particular, if anything it will need to beQListWidgetItem::height()
. -
wrote on 21 Jun 2018, 11:17 last edited by
-
wrote on 21 Jun 2018, 11:32 last edited by
@Prince_0912
In that link the example is:QListWidgetItem->setSizeHint(QSize((listWidget->width()),(listWidget->height()/4)));
which is quite different because it divides the list widget's height by 4 to fit 4
QListWidgetItem
s vertically. If the OP uses your suggestion, it won't come out anything like he is asking for. Up to you & him. -
@Prince_0912
In that link the example is:QListWidgetItem->setSizeHint(QSize((listWidget->width()),(listWidget->height()/4)));
which is quite different because it divides the list widget's height by 4 to fit 4
QListWidgetItem
s vertically. If the OP uses your suggestion, it won't come out anything like he is asking for. Up to you & him.wrote on 21 Jun 2018, 11:35 last edited by amarism@JonB When I use this code it will convert the whole height into 4 part. But I need to just break the text whose extra than image and print just below the main original text.
For Example, my extra text size is this and I want to cut the red part text and print below the text. -
@JonB When I use this code it will convert the whole height into 4 part. But I need to just break the text whose extra than image and print just below the main original text.
For Example, my extra text size is this and I want to cut the red part text and print below the text.@amarism If I undesrand you correctly you need ward wrapping. I#M not sure QListWidget supports it, maybe you can do it via styles?
-
wrote on 21 Jun 2018, 13:11 last edited by
-
wrote on 21 Jun 2018, 13:21 last edited by
@VRonin
In that doc it states:Please note that even if wrapping is enabled, the cell will not be expanded to make room for the text. It will print ellipsis for text that cannot be shown, according to the view's textElideMode.
I wonder whether it will expand vertically given that statement?
-
@VRonin
In that doc it states:Please note that even if wrapping is enabled, the cell will not be expanded to make room for the text. It will print ellipsis for text that cannot be shown, according to the view's textElideMode.
I wonder whether it will expand vertically given that statement?
wrote on 21 Jun 2018, 13:23 last edited by@JonB said in ListWidget Text size fixed:
I wonder whether it will expand vertically given that statement?
Indeed it won't that's the job of the delegate's
sizeHint
method -
@VRonin
In that doc it states:Please note that even if wrapping is enabled, the cell will not be expanded to make room for the text. It will print ellipsis for text that cannot be shown, according to the view's textElideMode.
I wonder whether it will expand vertically given that statement?
1/13