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
@
QWidget* window = new QWidget;
QVBoxLayout* layout = new QVBoxLayout(window);
QPushButton* optsButton = new QPushButton("Options");
QPushButton* exitButton = new QPushButton("Exit");QLabel *name = new QLabel("some text which makes the vertical scroll enble"); name->setWordWrap(true); name->setMaximumWidth(320-35); layout->addWidget(name); layout->addWidget(optsButton); layout->addWidget(name); layout->addWidget(exitButton); layout->addWidget(name); QScrollArea* scr = new QScrollArea; scr->setWidget(window); scr->setWidgetResizable(false); scr->setBackgroundRole(QPalette::Dark); scr->show();
@
I will be really thankful if some one give me even any hint regarding that.
-
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:
Use another widget as suggested by ludde above. You can also considder QTextBrowser for this task.
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.
-
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.
-
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 ?
-
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.