This looks like the text edit being a cild of the tab instead of being inside the scrollarea.
Since you want more than one widget inside the scrollarea, add a normal and empty QWidget into it, see QScrollArea::setWidget()
Then add your text edits to that widget, using whatever layout you find appropriate.
Cheers,
_
I've done what you told me but the scrollbars are not showing up. My code:
Qt Code:
//my constructor ui.scrollArea->setWidget(container); //that I add to my scrollArea //this my text Edit's creation connect(txt->document(), SIGNAL(contentsChanged()), this, SLOT(update_size())); txt->installEventFilter(this); txt->setTextColor(fontColor); txt->show();To copy to clipboard, switch view to plain text mode
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,
_
How do you suggest that I do that? I tried that but still not working:Qt Code:
ui.scrollArea->setWidget(container); container->setLayout(layout); ui.scrollArea->setWidgetResizable(true);To copy to clipboard, switch view to plain text mode
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,
_
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.
The designer ui file is attached, the Form.ui is a link.
Cheers,
_
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:
//my .h file QVBoxLayout* layout; QTextEdit* txt; QWidget* container; //my .cpp file //Constructor ui.scrollArea->setWidget(container); container->setLayout(layout); ui.scrollArea->setLayout(layout); ui.scrollArea->setWidgetResizable(true); //Slot which creates my textEdits txt->setParent(container); connect(txt->document(), SIGNAL(contentsChanged()), this, SLOT(update_size())); txt->installEventFilter(this); txt->setTextColor(fontColor); txt->show();To copy to clipboard, switch view to plain text mode
You are missing the layout->addWidget(txt) call.
Cheers,
_
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![]()
Bookmarks