Results 1 to 6 of 6

Thread: Scrollbar always grayed out

  1. #1
    Join Date
    Feb 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Scrollbar always grayed out

    Hello,

    i used QtDesigner for placing a QScrollArea into a QWidget and placing a QGridLayout into this QScrollArea. Now i add QLabels into the GridLayout

    Qt Code:
    1. QLabel *lab = new QLabel();
    2. lab->setPixmap(QPixmap::fromImage(img));
    3. lab->setMinimumSize(img.size());
    4. m_ui.gridLayout->addWidget(lab, m_currentRow, m_currentColumn);
    5. }
    To copy to clipboard, switch view to plain text mode 

    The Labels are added and displayed correctly, but if i add more labels than my Widget can display, the scrollbars (ScrollbarAlwaysOn) are still grayed out.
    What has to be done?

    Thanks in advance
    Garg

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Scrollbar always grayed out

    set the "widgetResizable" property of the scroll area to true.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Scrollbar always grayed out

    it is true...

    here is the code generated from QtDesigner

    Qt Code:
    1. QScrollArea *scrollArea;
    2. QWidget *scrollAreaWidgetContents;
    3. QWidget *gridLayoutWidget;
    4. QGridLayout *gridLayout;
    5.  
    6. void setupUi(QWidget *ImageViewerClass)
    7. {
    8. //...
    9. scrollArea = new QScrollArea(ImageViewerClass);
    10. QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    11. sizePolicy.setHorizontalStretch(0);
    12. sizePolicy.setVerticalStretch(0);
    13. sizePolicy.setHeightForWidth(scrollArea->sizePolicy().hasHeightForWidth());
    14. scrollArea->setSizePolicy(sizePolicy);
    15. scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    16. scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    17. scrollArea->setWidgetResizable(true);
    18. scrollAreaWidgetContents = new QWidget();
    19.  
    20. gridLayoutWidget = new QWidget(scrollAreaWidgetContents);
    21. gridLayout = new QGridLayout(gridLayoutWidget);
    22. gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
    23. gridLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
    24. gridLayout->setContentsMargins(0, 0, 0, 0);
    25. scrollArea->setWidget(scrollAreaWidgetContents);
    To copy to clipboard, switch view to plain text mode 

    I dont know where i can find more information (looked into api, qt-book, goole)

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Scrollbar always grayed out

    And how do you add the labels to the widget? Could you post the ui file? Mine is attached and works fine.
    Attached Files Attached Files
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Scrollbar always grayed out

    they are added at runtime

    Qt Code:
    1. void ImageViewer::addImage(const QImage &img)
    2. {
    3. QLabel *lab = new QLabel();
    4. lab->setPixmap(QPixmap::fromImage(img));
    5. lab->setMinimumSize(img.size());
    6. m_ui.gridLayout->addWidget(lab, m_currentRow, m_currentColumn);
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 

    mine makes it the indirect way about "GridLayoutWidget"
    Last edited by Gargolissimus; 6th July 2009 at 19:49.

  6. #6
    Join Date
    Feb 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Scrollbar always grayed out

    Now i coded it manually without using VS Integration and it works ;-) seems to generate stupid code?

    ty

Similar Threads

  1. Horizontal scrollbar problem
    By blaylockr in forum Newbie
    Replies: 2
    Last Post: 21st July 2008, 17:38
  2. ScrollBar inside QTreeWidget is Blurring on Scrolling
    By santosh.kumar in forum Qt Programming
    Replies: 0
    Last Post: 11th April 2008, 14:33
  3. Treeview scrollbar not updating when inserting rows
    By Khal Drogo in forum Qt Programming
    Replies: 11
    Last Post: 29th November 2007, 13:13
  4. GraphicsView/GraphicsScene: scrollbar policy Qt::ScrollBarAsNeeded
    By Pieter from Belgium in forum Qt Programming
    Replies: 4
    Last Post: 21st March 2007, 13:15
  5. about scrollbar style
    By qtopiahooo in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2007, 13:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.