PDA

View Full Version : MAC ONLY- Vertical Scroll problem with QTableWidget



user_mail07
25th March 2013, 17:33
Hello Everyone.

In QTable Widget, i am adding some items in certain columns using “setCellWidget()”. Whereas, to add items in other columns of the same row I am using “setItem()”.
When I tried to use vertical scroll bar, the items added by using “setItem()” scroll properly. But the items added by “setCellWidget()” do not scroll at all . They are frozen.

I tried following options:-

[1] I tried setting the stylesheet –
QString scrollStyleSheet = “QTableWidget {}”; // tried few variations too , but this works the best
ui->deviceGridTable->setStyleSheet(scrollStyleSheet );

It works fine, so long as I do not scroll, when items are getting added. Before adding new items or after adding new items, if I scroll, it works fine. However, if I scroll, while new items are being added one by one , it shows the same old ugly characteristics which I just described.

[2] I tried setting “VerticalScrollMode” to “ScrollPerPixel”. It does not work at all.

What else can I try to fix the problem of vertical scrolling while items are detting added ? (Only for those items which are added using “setCellWidget()”. The problem is only on Mac OSX 10.8.1. I am using Qt 4.8.3

Thanks a lot.

karankumar1609
26th March 2013, 04:57
Same thread exists but no reply
http://www.qtcentre.org/threads/53874-Qt-QTableWidget-Cell-Widget-static-position-on-MacOsX

I have also seen a reply but unable to get my problem resolved...

Have a look if u got your problem solved then let me know.
http://stackoverflow.com/questions/15331256/qlistwidget-with-custom-widget-does-not-scroll-properly-in-mac-os

karankumar1609
26th March 2013, 10:42
After a long compiling of Qt source .... and YAY
i got my problem resolved....
I applied this patch provided to me by Qt Commercial Support. This resolved my Mac scroll problems on Qt 4.8.5:



--- /Users/irfanomair/dev/qt-src-carbon-4.8.0/src/gui/kernel/qwidget_mac.mm 2011-12-15 10:38:21.000000000 -0800
+++ kernel/qwidget_mac.mm 2012-09-18 17:17:03.000000000 -0700
@@ -1,22 +1,41 @@

@@ -4684,15 +4703,14 @@
}

// Scroll the whole widget if qscrollRect is not valid:
- QRect validScrollRect = qscrollRect.isValid() ? qscrollRect : q->rect();
- validScrollRect &= clipRect();
+ QRect validScrollRect = qscrollRect.isValid() ? qscrollRect : QRect(0, 0, q->width(), q->height());

// If q is overlapped by other widgets, we cannot just blit pixels since
// this will move overlapping widgets as well. In case we just update:
const bool overlapped = isOverlapped(validScrollRect.translated(data.crect .topLeft()));
const bool accelerateScroll = accelEnv && isOpaque && !overlapped;
const bool isAlien = (q->internalWinId() == 0);
- const QPoint scrollDelta(dx, dy);
+

// If qscrollRect is valid, we are _not_ supposed to scroll q's children (as documented).
// But we do scroll children (and the whole of q) if qscrollRect is invalid. This case is
@@ -4714,7 +4732,6 @@
}else {
update_sys(qscrollRect);
}
- return;
}

#ifdef QT_MAC_USE_COCOA
@@ -4731,6 +4748,7 @@
// moved when the parent is scrolled. All directly or indirectly moved
// children will receive a move event before the function call returns.
QWidgetList movedChildren;
+ const QPoint scrollDelta(dx, dy);
if (scrollChildren) {
QObjectList children = q->children();