no horizontal scroll bar in QTableWidget
hi.
i want to create search results window, so i put QTextBrowsers in QTableWidget's cells using setCellWidget. there is a problem: horizontal scroll bar in QTableWidget is never appears in contrast to the vertical, which is appears when its needed. all scroll bar settings are default.
how can i get this scroll when its needed? and even when i set horizontalScrollBarPolicy in alwaysOn, there is no slider on it even when it should be.
and also how to adjust table's cell size to full browser's text size?
there is some sample code
Code:
// ui->tw is a QTableWidget
ui->tw->insertRow(0);
b->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
b->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
b->setHtml(tr("some <b>HTML</b> <i>marked</i> search result <u>that does not fit in table cell without scroll bar</u>"));
ui->tw->setCellWidget(0,0,b);
Re: no horizontal scroll bar in QTableWidget
use
Code:
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
1 Attachment(s)
Re: no horizontal scroll bar in QTableWidget
Quote:
Originally Posted by
Ashkan_s
use
Code:
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
its not working. Qt::ScrollBarAsNeeded is a default value that used in designer. i tried to set it manualy, thats what i got:Attachment 8313
Re: no horizontal scroll bar in QTableWidget
I think this is because you have only one column (at least it seems so from the picture) and the column (not its contents) is visible so scrolling is not needed.
Re: no horizontal scroll bar in QTableWidget
Quote:
Originally Posted by
Ashkan_s
I think this is because you have only one column (at least it seems so from the picture) and the column (not its contents) is visible so scrolling is not needed.
thats right. i have added second column and scroll was appeared. thank you very much!;)
but what is the reason of that behavior? am i have to add a fictive column to see the scroll?
Re: no horizontal scroll bar in QTableWidget
Quote:
am i have to add a fictive column to see the scroll?
try this: change the scrolling mode to ScrollPerPixel and set a minimum width for the QTableWidget's horizontal header, for example
Code:
tb.horizontalHeader()->setMinimumWidth(minwidth);
here tb is QTableWidget.
Re: no horizontal scroll bar in QTableWidget
Re: no horizontal scroll bar in QTableWidget
Putting text browser instances in QTableWidget is not the right thing to do here. If you need rich text (I'm assuming that's why you put QTextBrowser there), you should implement a rich text delegate for your table widget.
Re: no horizontal scroll bar in QTableWidget
Quote:
Originally Posted by
wysota
Putting text browser instances in
QTableWidget is not the right thing to do here.
thank you for your participation. i've been googled some about "rich text delegate" and found this topic. this is what you had in mind?
Re: no horizontal scroll bar in QTableWidget
Yes, something like that.
Re: no horizontal scroll bar in QTableWidget
Quote:
Originally Posted by
moskk
thank you for your participation. i've been googled some about "rich text delegate" and found
this topic. this is what you had in mind?
hi,
then put an entire dialog as QTableWidgetItem in QTable in not correct ??
ty
Re: no horizontal scroll bar in QTableWidget