Results 1 to 8 of 8

Thread: No ScrollBar in QGraphicsView

  1. #1
    Join Date
    Feb 2009
    Posts
    189
    Thanks
    2

    Default No ScrollBar in QGraphicsView

    Dear Friends
    I have some QGraphicsItems in the QGraphicsScene which is visualized by QGraphicsView. I am doing some translation so that my item is getting out of the view.Some part is not visible. I am getting no horizontal scrollbar to see it..How could I set this mechanism so that whenever my items is out I should get a scrollbar.

  2. #2
    Join Date
    Dec 2007
    Posts
    627
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: No ScrollBar in QGraphicsView

    Set properties :
    setVerticalScrollBarPolicy();
    setHorizontalScrollBarPolicy();
    Last edited by yogeshgokul; 20th August 2009 at 12:42.

  3. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: No ScrollBar in QGraphicsView

    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  4. #4
    Join Date
    Feb 2009
    Posts
    189
    Thanks
    2

    Default Re: No ScrollBar in QGraphicsView

    Even if I put a scrollbar using setHorizontalScrollbarPolicy() then it's seen but I can't scroll if my item is translated and getting out of the view.
    I think this is some other problem.I am not setting any setSceneRect for my view.Do I need to set always a rect using setSceneRect....What is the fundamental can anybody expliain me....

    Whelese could be the reason. ??

  5. #5
    Join Date
    Aug 2008
    Posts
    60
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: No ScrollBar in QGraphicsView

    Hi,
    I am facing the same problem, did you got any clue ??? pl. share.
    Thank you.

  6. #6
    Join Date
    Dec 2007
    Posts
    627
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: No ScrollBar in QGraphicsView

    Hi guys.
    Please run this test code.
    You will see, the scrollbars comes automatically.
    Because the GV cannot show the full line.
    I hope you are getting my point.

    Qt Code:
    1. #include <QApplication>
    2. #include <QGraphicsScene>
    3. #include <QGraphicsView>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8. QApplication::setStyle("plastique");
    9. scene.addLine(0,0,2000,2000);
    10. QGraphicsView view(&scene);
    11. view.show();
    12. return a.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Aug 2008
    Posts
    60
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: No ScrollBar in QGraphicsView

    Hi yogeshgokul,

    If you add items from scene then it scrolls, that is fine.
    The problem I am facing is I am drawing text using QPointer in QGraphicsView::drawForeground(), in this case the text gets cuts towards the rigth side of the view and it is not showing scrollbars.
    do you have any idea for this case ?
    Thank you.

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

    Default Re: No ScrollBar in QGraphicsView

    You have to set the scene size properly and the scrollbars will appear.
    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.


Similar Threads

  1. Replies: 0
    Last Post: 5th March 2009, 07:54
  2. Bug in QGraphicsView? ScrollBar problems
    By estanisgeyer in forum Qt Programming
    Replies: 7
    Last Post: 13th March 2008, 18:44
  3. Treeview scrollbar not updating when inserting rows
    By Khal Drogo in forum Qt Programming
    Replies: 11
    Last Post: 29th November 2007, 14:13
  4. GraphicsView/GraphicsScene: scrollbar policy Qt::ScrollBarAsNeeded
    By Pieter from Belgium in forum Qt Programming
    Replies: 4
    Last Post: 21st March 2007, 14:15
  5. about scrollbar style
    By qtopiahooo in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2007, 14: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.