Notices


Reply
Thread Tools
Posts: 325 | Thanked: 341 times | Joined on Jan 2011 @ Brisbane, Australia
#1
Ive looked through;
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?
 

The Following User Says Thank You to azkay For This Useful Post:
Posts: 435 | Thanked: 763 times | Joined on Apr 2010
#2
If you're using QtDesigner, right click inside the QScrollArea and pick a layout, than you can start adding your labels.

If the scroll area is a lot bigger, than expand your main window to the bottom and make a QWidget where you place all your objects, than in the MainWindow constructor set this widget inside the scrollArea: ui->scrollArea->setWidget(ui->widget);
 

The Following User Says Thank You to gionni88 For This Useful Post:
Posts: 325 | Thanked: 341 times | Joined on Jan 2011 @ Brisbane, Australia
#3
Thanks, I dont know how I missed that.
 

The Following User Says Thank You to azkay For This Useful Post:
pichlo's Avatar
Posts: 2,495 | Thanked: 5,289 times | Joined on Sep 2012 @ UK
#4
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:
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();
}
It crashes on the painter.fillRect line, as verified by sticking qDebug before and after. Values of w and h were:

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 pichlo For This Useful Post:
Posts: 462 | Thanked: 650 times | Joined on Jan 2009
#5
Originally Posted by pichlo View Post
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:
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();
}
It crashes on the painter.fillRect line, as verified by sticking qDebug before and after. Values of w and h were:

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.
Interesting problem. I haven't done Qt in a while. Do you have any source to test with? Is this Maemo 5?

You may also find hints in the Qalendar source code. The author does a lot of his own drawing in there. Very clean code.
 

The Following 2 Users Say Thank You to jackburton For This Useful Post:
marxian's Avatar
Posts: 2,365 | Thanked: 8,803 times | Joined on Aug 2010 @ Wigan, UK
#6
I did a simple test using a QScrollArea and a plain QWidget, and was able to continue expanding the size of the widget without any problem:



Perhaps you could try substituting the QGLWidget for a QWidget to see if the problem is related to QGLWidget.

It might also be worth showing the setup code for the QScrollArea and child widget (do you have 'widgetResizable' enabled and so on).
__________________
“How the f**k else would you do this job? Cocaine and hookers, my friend.”

My website

GitHub
 

The Following 3 Users Say Thank You to marxian For This Useful Post:
pichlo's Avatar
Posts: 2,495 | Thanked: 5,289 times | Joined on Sep 2012 @ UK
#7
Here are the initializing bits:

1) mainwindow.ui (relevant part only)
Code:
      <item>
       <widget class="QScrollArea" name="scrollArea">
        <property name="widgetResizable">
         <bool>true</bool>
        </property>
       </widget>
      </item>
2) mainwindow.h (simplified)
Code:
#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;
};
3) mainwindow.cpp (simplified)
Code:
MainWindow::MainWindow (QWidget *parent)
  : StackedMainWindow(parent)
  , preview(this)
  , scaleFactor(1.0)
{
  ui.setupUi(this);
  ui.scrollArea->setWidget(&preview);
}
I will try replacing QGLWidget with QWidget. It might be a QGLWidget problem after all, not QScrollArea one. In the meantime, I made another experiment with the only thing changed is reducing the scale factor from 1.5 to 1.25. The result...

w=668, h=424
w=835, h=416
w=1043, h=416
w=1043, h=416
w=1304, h=416
w=1630, h=416
w=2038, h=416
w=2548, h=416, crash!

So it does seem to be size related.
 

The Following 2 Users Say Thank You to pichlo For This Useful Post:
Posts: 1,522 | Thanked: 4,271 times | Joined on Dec 2010 @ Dayton, Ohio
#8
Another item to test: you could try just placing the Preview widget directly into the UI without embedding it within a QScrollArea widget. I kind of get the feeling that if this is a memory overrun or a clipping error, it'd be more likely to happen closer to the widget with the actual image data. I kind of doubt that QScrollArea would be so sensitive to the physical size of the image...

BTW, on kinetic scrolling: it seems you can enable kinetic scrolling on most any Qt Maemo widget that can scroll. You can manipulate this feature (turning it on or off, retrieving various scrolling info, or messing around with it in general) by accessing the "kineticScroller" property of the widget. For example, this would switch on kinetic scrolling for a widget called "scrollArea":

Code:
 QAbstractKineticScroller *scroller = scrollArea->property("kineticScroller").value<QAbstractKineticScroller *>();

 if (scroller)
     scroller->setEnabled(true);
There's a bunch more info in the Qt docs about this.
 

The Following 3 Users Say Thank You to Copernicus For This Useful Post:
marxian's Avatar
Posts: 2,365 | Thanked: 8,803 times | Joined on Aug 2010 @ Wigan, UK
#9
Originally Posted by Copernicus View Post
BTW, on kinetic scrolling: it seems you can enable kinetic scrolling on most any Qt Maemo widget that can scroll.
I think the only widgets that can scroll are those derived from QAbstractScrollArea (QScrollArea and the item views/widgets) and QWebView. Those are the only widgets I know of that have a QAbstractKineticScroller.
__________________
“How the f**k else would you do this job? Cocaine and hookers, my friend.”

My website

GitHub
 

The Following 4 Users Say Thank You to marxian For This Useful Post:
jflatt's Avatar
Posts: 531 | Thanked: 710 times | Joined on Oct 2009
#10
Max texture size and max render buffer on SGX 530 is 2048x2048
 

The Following 4 Users Say Thank You to jflatt For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 02:58.