The Following User Says Thank You to azkay For This Useful Post: | ||
![]() |
2011-05-04
, 07:03
|
Posts: 435 |
Thanked: 769 times |
Joined on Apr 2010
|
#2
|
The Following User Says Thank You to gionni88 For This Useful Post: | ||
![]() |
2014-07-16
, 20:51
|
|
Posts: 6,450 |
Thanked: 20,983 times |
Joined on Sep 2012
@ UK
|
#4
|
void Preview::paintGL () { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); const int w = width(); const int h = height(); // Paint the background painter.fillRect(0, 0, w, h, Qt::white); // ... a few dozen more lines ... painter.end(); }
The Following 2 Users Say Thank You to pichlo For This Useful Post: | ||
![]() |
2014-07-16
, 21:15
|
Posts: 466 |
Thanked: 661 times |
Joined on Jan 2009
|
#5
|
Is reviving a 3yo thread better or worse than creating a new one?
Anyway, I have a QScrollArea that covers most of the screen. Inside it, I have a widget of type Preview, derived from QGLWidget.
I also have zoom buttons. Zoom affects the horizontal size only, the vertical dimension is fixed. The problem is that zooming in more than two times segfaults the program.
Here is the relevant bit where it segfaults:
It crashes on the painter.fillRect line, as verified by sticking qDebug before and after. Values of w and h were:Code:void Preview::paintGL () { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); const int w = width(); const int h = height(); // Paint the background painter.fillRect(0, 0, w, h, Qt::white); // ... a few dozen more lines ... painter.end(); }
w=668, h=416, OK (starting point)
w=1002, h=416, OK (zoom in x1)
w=1503, h=416, OK (zoom in x2)
w=2254, h=416, crash!
What is going on? Can the device not handle painting areas of that size? (Code written, built and run entirely on the phone.)
Given the experience, I am inclined to rewrite the code to eliminate QScrollArea altogether and instead do my own redrawing the preview with moving starting point. What options do I have to drag the picture left or right with the finger? I would really prefer not to try implementing my own version of kinetic scrolling if I can.
The Following 2 Users Say Thank You to jackburton For This Useful Post: | ||
![]() |
2014-07-16
, 21:16
|
|
Posts: 2,448 |
Thanked: 9,523 times |
Joined on Aug 2010
@ Wigan, UK
|
#6
|
The Following 3 Users Say Thank You to marxian For This Useful Post: | ||
![]() |
2014-07-16
, 21:44
|
|
Posts: 6,450 |
Thanked: 20,983 times |
Joined on Sep 2012
@ UK
|
#7
|
<item> <widget class="QScrollArea" name="scrollArea"> <property name="widgetResizable"> <bool>true</bool> </property> </widget> </item>
#include "stackedmainwindow.h" #include "ui_mainwindow.h" #include "preview.h" class MainWindow : public StackedMainWindow { Q_OBJECT public: explicit MainWindow (QWidget *parent = 0); private slots: void on_buttonZoomHome_clicked (); void on_buttonZoomIn_clicked (); void on_buttonZoomOut_clicked (); private: Ui::MainWindow ui; Preview preview; double scaleFactor; };
MainWindow::MainWindow (QWidget *parent) : StackedMainWindow(parent) , preview(this) , scaleFactor(1.0) { ui.setupUi(this); ui.scrollArea->setWidget(&preview); }
The Following 2 Users Say Thank You to pichlo For This Useful Post: | ||
![]() |
2014-07-16
, 22:38
|
|
Posts: 1,986 |
Thanked: 7,698 times |
Joined on Dec 2010
@ Dayton, Ohio
|
#8
|
QAbstractKineticScroller *scroller = scrollArea->property("kineticScroller").value<QAbstractKineticScroller *>(); if (scroller) scroller->setEnabled(true);
The Following 3 Users Say Thank You to Copernicus For This Useful Post: | ||
![]() |
2014-07-16
, 22:52
|
|
Posts: 2,448 |
Thanked: 9,523 times |
Joined on Aug 2010
@ Wigan, UK
|
#9
|
BTW, on kinetic scrolling: it seems you can enable kinetic scrolling on most any Qt Maemo widget that can scroll.
The Following 4 Users Say Thank You to marxian For This Useful Post: | ||
![]() |
2014-07-16
, 23:09
|
|
Posts: 534 |
Thanked: 723 times |
Joined on Oct 2009
|
#10
|
The Following 4 Users Say Thank You to jflatt For This Useful Post: | ||
http://wiki.maemo.org/Qt4_Hildon_Leg...etic_scrolling
http://doc.qt.nokia.com/qt-maemo-4.6...tml#setEnabled
http://doc.qt.nokia.com/qt-maemo-4.6...-textedit.html
I still cant get a scrollable gui working.
Basically, im trying to make a QScrollArea and be able to, well, kinetic scrolling.
I plan on have lots of text labels and images, I am wanting to be able to scroll down the GUI to be able to read them.
Anyone got an example?