ListWidget Text size fixed
-
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
-
@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
@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()))));@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()
. -
@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.@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. -
-
@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?
-
@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?