I am not sure I understand the problem, but why not add the scrolll area in designer?
Cheers,
_
I am not sure I understand the problem, but why not add the scrolll area in designer?
Cheers,
_
I've tried to do it on Designer but it doesn't work. My problem is: I add some textEdits which have my qtabWidget as "parent". Those textEdit grow bigger each time you add text in them (so that you always see the full text). But when they are bigger than the qtabwidget (they need to be because the user needs to have plenty of space to be able to write a lot of things) I would like my QTabWidget to display a vertical scrollbar so that the user can see what he has been writing.
My problem with designer is that the scrollArea is that it doesn't take my qtabWidget size (it's not taking the entire tabs and it doesn't display the scrollbars).
My problem with my code is that I've got to create a new Tab to make the scrollArea take the entire size of my tab and it's not working. On top of that I'd like my background to be white and not grey as it is when I compile. Here's a screenshot of what I have:
with designer: reza.jpg
with my code: aze.jpg
Last edited by Yaoming; 18th January 2014 at 17:37.
Sounds like your tab is missing the layout. Check that you have a layout assigned to the tab.
Cheers,
_
There's one (I think). Here's a screenshot of my QtDesigner for my QTabWidget (named "Onglets")eaz.PNG
Indeed. Since it is a QGridLayout the problem could be that the scroll area is not spanning across all columns. This can be a bit tricky in designer but is doable with a bit of experiementation.
However, now that the "main" widget of the tab should be the scroll area, maybe you can reduce the number of spacers, e.g. just one horizontal and one vertical to keep the button in the top right corner.
This should make it easier to place the scroll area.
Cheers,
_
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.
Bookmarks