Results 1 to 17 of 17

Thread: ScrollArea in a tabWidget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ScrollArea in a tabWidget

    The container does not have a layout. So if the size of the text edit increases it does not increase the size of the container.

    Cheers,
    _

  2. #2

    Default Re: ScrollArea in a tabWidget

    How do you suggest that I do that? I tried that but still not working:
    Qt Code:
    1. container = new QWidget();
    2. layout = new QVBoxLayout();
    3. ui.scrollArea->setWidget(container);
    4. container->setLayout(layout);
    5. ui.scrollArea->setWidgetResizable(true);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ScrollArea in a tabWidget

    Yes, like that.

    I just did a quick experiement in designer and I get scroll bars when the scroll area is smaller than the text edits inside it.
    Form.ui

    Cheers,
    _

  4. #4

    Default Re: ScrollArea in a tabWidget

    Could you please give me your code? Because what I have is not working... I've tried different ways but in vain.
    Last edited by Yaoming; 20th January 2014 at 12:33.

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ScrollArea in a tabWidget

    The designer ui file is attached, the Form.ui is a link.

    Cheers,
    _

  6. #6

    Default Re: ScrollArea in a tabWidget

    Ok but you did it with Designer. In my case, I can't... Here's all my code for this part, do you see any mistakes? Would you have done it differently?
    Qt Code:
    1. //my .h file
    2. QVBoxLayout* layout;
    3. QTextEdit* txt;
    4. QWidget* container;
    5.  
    6. //my .cpp file
    7. //Constructor
    8. container = new QWidget();
    9. layout = new QVBoxLayout();
    10. ui.scrollArea->setWidget(container);
    11. container->setLayout(layout);
    12. ui.scrollArea->setLayout(layout);
    13. ui.scrollArea->setWidgetResizable(true);
    14.  
    15. //Slot which creates my textEdits
    16. txt = new QTextEdit();
    17. txt->setParent(container);
    18. connect(txt->document(), SIGNAL(contentsChanged()), this, SLOT(update_size()));
    19. txt->installEventFilter(this);
    20. txt->setFont(QFont("Times New Roman", fontSize));
    21. txt->setTextColor(fontColor);
    22. txt->show();
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ScrollArea in a tabWidget

    You are missing the layout->addWidget(txt) call.

    Cheers,
    _

  8. #8

    Default Re: ScrollArea in a tabWidget

    Still not working... Anyway you've helped me a lot so I'm going to try and figure it out by myself and stop bothering you.
    Thanks for your help

Similar Threads

  1. Help me about QGridLayout and ScrollArea
    By homerux in forum Newbie
    Replies: 3
    Last Post: 12th August 2013, 00:11
  2. scrollArea
    By skizzik in forum Qt Programming
    Replies: 1
    Last Post: 12th January 2011, 12:55
  3. ItemViews in ScrollArea
    By SElsner in forum Newbie
    Replies: 3
    Last Post: 4th June 2010, 23:59
  4. Autoscroll in ScrollArea
    By BalaQT in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2009, 05:37
  5. QTreeWidget without the ScrollArea?
    By Paalrammer in forum Newbie
    Replies: 5
    Last Post: 13th February 2007, 19:06

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.