Results 1 to 9 of 9

Thread: scrollAreaWidgetContents not available when scroll area declared in code

  1. #1
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default scrollAreaWidgetContents not available when scroll area declared in code

    I used scrollArea widget before, that time i created it in designer and to add the widgets into it i did as below

    Qt Code:
    1. ui->scrollAreaWidgetContents->layout()->addWidget(checkbox);
    2. ui->scrollAreaWidgetContents->layout()->addWidget(ComboOperator);
    To copy to clipboard, switch view to plain text mode 
    But now i wanted to create one more scroll area programattically(without designer)
    I declared as below...

    Qt Code:
    1. sarea->layout()->addWidget(checkbox);
    2. sarea->layout()->addWidget(ComboOperator);
    To copy to clipboard, switch view to plain text mode 


    And when i tried to put inside it, program was crashing.
    Here i didnt get option to use scrollAreaWidgetContents, as it was available in designer....
    Please tell me what wrong here...

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: scrollAreaWidgetContents not available when scroll area declared in code

    Look what sarea->layout() is returning and think form there forward.

  3. #3
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: scrollAreaWidgetContents not available when scroll area declared in code

    sarea->widget()->layout()->addWodget(checkbox)

  4. #4
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: scrollAreaWidgetContents not available when scroll area declared in code

    Quote Originally Posted by MarekR22 View Post
    sarea->widget()->layout()->addWodget(checkbox)
    Sorry Marek, that's not working...same problem persist even aftr the changes...

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: scrollAreaWidgetContents not available when scroll area declared in code

    So have you checked what sarea->layout() or sarea->widget() is returning? What could ne the reason for that... Hmm...

  6. #6
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: scrollAreaWidgetContents not available when scroll area declared in code

    Quote Originally Posted by Lykurg View Post
    So have you checked what sarea->layout() or sarea->widget() is returning? What could ne the reason for that... Hmm...
    Ya Lykurg....i looked at that....
    Both returning Null...!!!!!!!!! Now what should i do ? How can i add widget into scroll area?

  7. #7
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: scrollAreaWidgetContents not available when scroll area declared in code

    Quote Originally Posted by aurora View Post
    How can i add widget into scroll area?
    You are familiar with the documentation? Open QScrollArea and search for lets say "add" and "widget". I bet you will find the function which adds widgets! The Detailed Description is always a good point to start.

  8. #8
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: scrollAreaWidgetContents not available when scroll area declared in code

    Qt Code:
    1. QWidget *contentW = QWidget();
    2. QBoxLayout *layout = new QBoxLayout(Qt::Vertical, contentW);
    3. layout->addWidget(checkbox);
    4. layout->addWidget(ComboOperator);
    5. sarea->setWidget(contentW);
    To copy to clipboard, switch view to plain text mode 

  9. #9
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: scrollAreaWidgetContents not available when scroll area declared in code

    MarekR22, don't you think aurora could have figured that out by him-/herself?

    And since it is such a trivial problem -> moved to Newbie section.

Similar Threads

  1. Scroll bars in scroll area not comming in scroll area
    By aurora in forum Qt Programming
    Replies: 3
    Last Post: 4th January 2012, 06:50
  2. Scroll bars in scroll area not comming
    By aurora in forum Qt Programming
    Replies: 3
    Last Post: 27th December 2011, 19:56
  3. Q Scroll Area that scrolls??
    By hakermania in forum Newbie
    Replies: 6
    Last Post: 24th August 2010, 19:48
  4. Scroll Area problem
    By Lodhart in forum Qt Programming
    Replies: 0
    Last Post: 10th October 2009, 13:03
  5. scroll area like QGraphicsItem
    By Gopala Krishna in forum Qt Programming
    Replies: 1
    Last Post: 7th February 2008, 11:28

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
  •  
Qt is a trademark of The Qt Company.