July 7, 2011

msalman msalman
Lab Rat
6 posts

Qscrollbar doesn’t show scroll bar on Qlabel

 

Hi,

I have to display a scrollable label, it contains some help text so it is bigger than the height of the screen, so i use scroll area to display that label. I have been able to scroll the label in C7 device but when i run it on E72 then the scroll bar doesn’t scroll.

Following is my code

  1.     QWidget* window = new QWidget;
  2.     QVBoxLayout* layout = new QVBoxLayout(window);
  3.     QPushButton* optsButton = new QPushButton("Options");
  4.     QPushButton* exitButton = new QPushButton("Exit");
  5.      
  6.     QLabel *name = new QLabel("some text which makes the vertical scroll enble");
  7.     name->setWordWrap(true);
  8.      
  9.     name->setMaximumWidth(320-35);
  10.     layout->addWidget(name);
  11.     layout->addWidget(optsButton);
  12.     layout->addWidget(name);
  13.     layout->addWidget(exitButton);
  14.     layout->addWidget(name);
  15.      
  16.     QScrollArea* scr = new QScrollArea;
  17.     scr->setWidget(window);
  18.     scr->setWidgetResizable(false);
  19.      
  20.     scr->setBackgroundRole(QPalette::Dark);
  21.     scr->show();

I will be really thankful if some one give me even any hint regarding that.

8 replies

July 7, 2011

ludde ludde
Ant Farmer
325 posts

Cannot help you with the non-functional scroll bar. But have you considered using a readonly QTextEdit or QPlainTextEdit instead?

July 7, 2011

Andre Andre
Area 51 Engineer
6031 posts

Only widgets derived from QAbstractScrollArea (or custom widgets that do this differently) provide a scrollbar. QLabel is not one of these.

You have two options:

  1. Use another widget as suggested by ludde above. You can also considder QTextBrowser for this task.
  2. Use a QScrollArea, and put a QLabel inside. Now, your label can grow as big as you need it to be. You probably should give it a maximum width though (and sync that with the maximum width of the scroll area itself), to prevent the scrolling to become horizontal instead of vertical.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

July 7, 2011

msalman msalman
Lab Rat
6 posts

I have also tried readonly QTextEdit but still it doesn’t scroll the scroll bar while i press key down :( Actually i have to show two labels and one image.

July 7, 2011

msalman msalman
Lab Rat
6 posts

Actually my layout is like on top there is a heading then i have to show an image then its description and finally a button, and i want to put a scrolllbar to whole screen so that user can move from top to bottom.

July 7, 2011

msalman msalman
Lab Rat
6 posts

Andre i have tried your second point in lots of different manner but in E72 it shows a scroll bar but when i pressed down key it doesn’t work.

July 7, 2011

Fuzzbender Fuzzbender
Lab Rat
71 posts

Since E72 is keypad-only device and it works in C7 (a touch device), I am fairly certain that it is due to the fact that the scrollarea does not have focus here. Therefore the keyevents go to the wind…

Try setting the focus to the scrollarea.

July 11, 2011

msalman msalman
Lab Rat
6 posts

I just read the QT document http://www.developer.nokia.com/Distribute/Packaging_and_signing.xhtml. As per this document E72 is not supported in QT 4.7 and above. Do you think this could be the issue ?? Should i target E series devices with QT 4.7 or leave it ?

July 11, 2011

Fuzzbender Fuzzbender
Lab Rat
71 posts

E72 is S60 3rd Edition device (FP2 to be exact). Latest Qt SDK is not intended for “old” S60 devices. But 4.7.x should still work there, you just might not target that device with your app through Ovi store.

I am still fairly certain that the above issue is due to focus getting lost in the non-touch device.

 
  ‹‹ Angry rant on the Qt Smart Installer for Symbian      need advice about video in app ››

You must log in to post a reply. Not a member yet? Register here!