Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qscrollbar doesn't show scroll bar on Qlabel
QtWS25 Last Chance

Qscrollbar doesn't show scroll bar on Qlabel

Scheduled Pinned Locked Moved Mobile and Embedded
9 Posts 4 Posters 21.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    msalman
    wrote on 7 Jul 2011, 06:42 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      ludde
      wrote on 7 Jul 2011, 07:07 last edited by
      #2

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

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on 7 Jul 2011, 07:32 last edited by
        #3

        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.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          msalman
          wrote on 7 Jul 2011, 07:33 last edited by
          #4

          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.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            msalman
            wrote on 7 Jul 2011, 07:40 last edited by
            #5

            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.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              msalman
              wrote on 7 Jul 2011, 07:53 last edited by
              #6

              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.

              1 Reply Last reply
              0
              • F Offline
                F Offline
                Fuzzbender
                wrote on 7 Jul 2011, 08:22 last edited by
                #7

                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.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  msalman
                  wrote on 11 Jul 2011, 06:54 last edited by
                  #8

                  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 ?

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    Fuzzbender
                    wrote on 11 Jul 2011, 17:36 last edited by
                    #9

                    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.

                    1 Reply Last reply
                    0

                    6/9

                    7 Jul 2011, 07:53

                    • Login

                    • Login or register to search.
                    6 out of 9
                    • First post
                      6/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved