[Interest] QSplitter + QScrollArea + QWidgetStack issues

Scott Aron Bloom scott.bloom at onshorecs.com
Fri Mar 28 07:38:58 CET 2014


Thanks.. Ill play with it some more tomorrow…

Scott
From: interest-bounces+scott.bloom=onshorecs.com at qt-project.org [mailto:interest-bounces+scott.bloom=onshorecs.com at qt-project.org] On Behalf Of maitai at virtual-winds.org
Sent: Thursday, March 27, 2014 11:34 PM
To: Interest at qt-project.org
Subject: Re: [Interest] QSplitter + QScrollArea + QWidgetStack issues


Hello,

I was faced with a similar exercice and solved if that way:

void Util::setDialogSize(QDialog *dialog)

{

    QDesktopWidget * desktopWidget = QApplication::desktop();

    QRect screenRect = desktopWidget->screenGeometry();

    dialog->setMaximumHeight(screenRect.height()-50);

    dialog->setMaximumWidth(screenRect.width()-20);

    QList<QScrollArea *> scrolls=dialog->findChildren<QScrollArea *>(QString(),Qt::FindDirectChildrenOnly);

    if(!scrolls.isEmpty())

    {

        QScrollArea * scrollarea=scrolls.at(0);

        int ws=scrollarea->horizontalScrollBar()->height();

        int ws1=scrollarea->verticalScrollBar()->height();

        ws=qMin(ws,ws1);

        scrollarea->setWidgetResizable(true);

        scrollarea->widget()->adjustSize();

        QSize s = QSize(scrollarea->widget()->sizeHint().width()+ws,scrollarea->widget()->sizeHint().height()+ws);

        if(s.height()>dialog->maximumHeight())

            s.setHeight(dialog->maximumHeight());

        if(s.width()>dialog->maximumWidth())

            s.setWidth(dialog->maximumWidth());

        dialog->resize(s);

    }

}

My case is a bit different because the QScrollArea is always at the top of the dialog.

I agree it it would be better to have something cleaner in qt to do that.

Regards,
Philippe Lelong



Le 28-03-2014 05:01, Scott Aron Bloom a écrit :
I have a dialogbox, with a vertical QSplitter as the top level layout..
on the left goes a QTreeWidget, on the right a QScrollArea
Inside the QScrollArea, there is a QWidgetStack in which multiple widgets are stacked.

Here is my problem, when it first comes up, I want the right hand side, to work as if the scroll area was not there.  Essential, just the stacked widget.  The user can then minimize and see the scroll bars.

I was hoping to use
scrollArea->maximumViewportSize(), but its not correct (too small).

Its laid out with Designer, so I don’t believe it’s a layout issue.. It works fine, except for the initial size.

To “kind” of get it to work, I go over each widget in the stacked widget, get the minimumSizeHint, I compute the largest combination of them.  Then I pad for the splitter width + the calculated minimum size of the tree.  Then I pad for the other widgets (a dialog button box outside the splitter etc etc)

But I just have to think, there should be some function somewhere, that I can call on a QScrollArea and say, find me an area that has no scroll bars, and use that as your initial size, and expand your parent widget.

Thanks in advance..

Scott


_______________________________________________

Interest mailing list

Interest at qt-project.org<mailto:Interest at qt-project.org>

http://lists.qt-project.org/mailman/listinfo/interest



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140328/1c4df213/attachment.html>


More information about the Interest mailing list