PDA

View Full Version : How to keep Qtablewidget last row always visible



vaibhav
17th January 2012, 13:29
Hi ,
I have Qtablewidget inside a QDialog,when my dialog is resized the tablewidget also gets resized and that i what the behavior i.e needed.

But when i resize my table widget or scroll the vertical ScrollBar .The last row Item is not completely visible so when user click's on that last row QT internally emit the valuechanged() to make it visible and the row is most 1 step up.

SO how can i keep my last row of tablewidget always visible irrespective of whether it is resized or it is scrolled so as to avoid the above behavior

Any help would be appreciated thanks......

wysota
17th January 2012, 23:31
I'm not sure I understand what you want but if I understand correctly that you want your view always showing the last item regardless of everything, then attach a custom signal to the vertical scrollbar's valueChanged() signal to a custom slot that will reset the scrollbar to its maximum value.

vaibhav
18th January 2012, 11:58
Setting the scroll bar to maximum value will bring it to it's Max position(Bottom).
But in my case even when the scroll bar is scrolled midway the last Item is partially visible, which i want to be completely visible so as to avoid valueChanged() signal when user clicks on that Item.

wysota
19th January 2012, 00:04
But in my case even when the scroll bar is scrolled midway the last Item is partially visible, which i want to be completely visible
That's why I suggest scrolling it to the end. Obviously you will get a value changed signal since the slider moves as a result of resizing the widget. If you want something different, then I'm sorry but you'll have to explain more because I can't understand you.

Spitfire
19th January 2012, 15:57
Or maybe use QAbstractItemView::scrollToBottom () on mouserelease/resize?

Btw what's the problem with valueChanged() signal being emitted?
I didn't understand what you're saying.

vani.pv
21st September 2012, 04:53
Hi .
I to have such kind of problem.

I need to insert a row to my qtablewidget when i click the INSERT button.

I have done like this.

ui->mytblwdgt->insertrow(ui->mutblwgt->currentrow() + 1);
but no row is added.
Can any one tell me how to fix it.



Thanks

ChrisW67
21st September 2012, 06:17
Firstly, this is not the same problem. This thread was about keeping the bottommost row of the table visible... nothing at all to do with new rows.

Secondly, adding a new row to a table widget, mytblwdgt, based on the current index of another table widget, mutblwgt, is probably going to work sometimes and not others. I am going to assume that you did not copy and paste your actual code and that this is a typo. If there is no current row in the table then you will probably get a new row 0, otherwise you should get a new row where requested. If you are not getting a new row then we cannot see where the error is based on one line of trivial code in isolation and no description of where you looked for the row. Post a small, self-contained demonstration (in
tags as you've been advised before) of the problem in the other thread you have asked this question in.