Results 1 to 2 of 2

Thread: implementing 'scrollview'

  1. #1
    Join Date
    Dec 2008
    My spaceship needs, I am stuck on beautiful earth
    Qt products
    Qt3 Qt4

    Red face implementing 'scrollview'

    Hi ,
    I created a simple form with a textlabel (textlabel1) and a dropdownbox .If you select any option from the dropdownbox,you should have a pic displayed in the textlabel and have scrollbars on the sides if picture size exceeds the textlabel's area.
    The problems that I am having are....
    1) The scrollview shows up with the scrollbars but the picture isn't displayed anywhere.

    2) If i have some text on top of my text label then a small portion of the picture appears in the background of the text.

    3)I tried to set the geometry of the textlabel but though it works when I comment out all the lines except textLabel1->setGeometry(100,80,300,200);

    But, as soon as I bring the scrollview into picture,it shows the above described results(1 & 2).
    I guess it might have something to dowith the label being made a child of the scrollview....I don't know how to get around this problem......Please provide a solution for it,I have been trying for the last 2 days(newbie)

    I have attached the code below,please check it out and let me know of the mistakes in it and what changes to make....working on Qt3.3
    Thanks in advance.

    Qt Code:
    1. #include<qscrollview.h>
    2. #include<qlabel.h>
    5. void Form1::showscrol()
    6. {
    7. QScrollView* sv = new QScrollView(this);
    9. sv->setVScrollBarMode(QScrollView::AlwaysOn);
    10. sv->setHScrollBarMode(QScrollView::AlwaysOn);
    11. sv->setGeometry(100,80,300,200);
    12. textLabel1->setGeometry(100,80,300,200);
    14. textLabel1->setPaletteBackgroundPixmap(QPixmap("/root/Albums/NEW/DSC01059.JPG"));
    15. sv->addChild(textLabel1,100,80);
    16. sv->show();
    19. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 18th December 2008 at 12:30. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Warsaw, Poland
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits

    Default Re: implementing 'scrollview'

    Try this:
    Qt Code:
    1. QScrollView *sv = new QScrollView(this);
    2. QLabel *label = new QLabel(sv->viewport());
    3. sv->addChild(label);
    4. label->setPixmap(myPixmap); // where myPixmap is... your pixmap
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to wysota for this useful post:

    rishiraj (19th December 2008)

Similar Threads

  1. linking error while implementing QMotifStyle
    By lzha022 in forum Qt Programming
    Replies: 17
    Last Post: 17th July 2008, 07:15
  2. thread implementing and stopping the thread
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 14th May 2007, 13:53
  3. implementing drawForeGround
    By Wirloff in forum Newbie
    Replies: 9
    Last Post: 11th April 2007, 16:03
  4. Implementing Resize funtionality
    By PiXeL16 in forum Qt Programming
    Replies: 2
    Last Post: 14th February 2007, 23:12
  5. filling scrollview
    By illuzioner in forum Qt Programming
    Replies: 1
    Last Post: 17th February 2006, 22:00


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.