[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] How to precisely control position/size of QDockWidgets
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2014-04-23 7:45:44
Message-ID: CAExHGmTzeTGXaH9Kyfu-zsR=yjONdzL7QZLxUXCnn793wP2zuQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

On Wed, Apr 23, 2014 at 12:18 AM, R Johnson (Gmail) <
ps16thypresenceisfullnessofjoy@gmail.com> wrote:

> Thank you for your helpful reply.
>
> QMainWindow.setCorner() does do what I wanted. I should have read the
> documentation more carefully about that, but couldn't find anything
> relevant on the QDockWidget page.
>
> Regarding specifying "the default width or height of the dock windows," I
> have attached another screenshot showing what I mean. The red rectangle
> shows the current width of the dock window, and the green one shows what I
> want the width to be. The default width wastes a lot of space in my layout.
> I have tried calling:
>
>     self.treewidget.sizeHint().setWidth(150)
>
> on the QTreeWidget that the dock window contains, but this has no effect.
>

sizeHint is just a getter for the preferred size. Its not changing the
sizeHint. The only way to change the result of the sizeHint function
directly is by subclassing and overriding sizeHint. That being said many
controls have other knobs that influence sizeHint.


> I also tried:
>
>     self.treewidget.resize(150, self.treewidget.height())
>
> but that didn't work either.
>
> If I make 150 pixels the maximum width of the dock window, then it is the
> width I want it, but it can't be made any wider. I don't want to make 150
> pixels the maximum (or minimum) width of the pane, just the default width.
> It also seems like the policy that I would want for QSizePolicy.setHorizontalPolicy()
> is QSizePolicy.Preferred, which is already the default one.
>

You could try an initial resizeColumnToContents() call which should make
column as wide as its contents are. This is of course slower if you have
lots of data. There's also ways to set the column width explicitly which
should also make the treeview smaller.

Andreas

[Attachment #5 (text/html)]

<div dir="ltr">Hi,<div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr \
23, 2014 at 12:18 AM, R Johnson (Gmail) <span dir="ltr">&lt;<a \
href="mailto:ps16thypresenceisfullnessofjoy@gmail.com" \
target="_blank">ps16thypresenceisfullnessofjoy@gmail.com</a>&gt;</span> wrote:<br> \
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">Thank you for your helpful reply.<br> <br>
QMainWindow.setCorner() does do what I wanted. I should have read the documentation \
more carefully about that, but couldn&#39;t find anything relevant on the QDockWidget \
page.<br> <br>
Regarding specifying &quot;the default width or height of the dock windows,&quot; I \
have attached another screenshot showing what I mean. The red rectangle shows the \
current width of the dock window, and the green one shows what I want the width to \
be. The default width wastes a lot of space in my layout. I have tried calling:<br>

<br>
      self.treewidget.sizeHint().<u></u>setWidth(150)<br>
<br>
on the QTreeWidget that the dock window contains, but this has no \
effect.<br></blockquote><div><br></div><div>sizeHint is just a getter for the \
preferred size. Its not changing the sizeHint. The only way to change the result of \
the sizeHint function directly is by subclassing and overriding sizeHint. That being \
said many controls have other knobs that influence sizeHint.</div> <div>  \
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> I also tried:<br>
<br>
      self.treewidget.resize(150, self.treewidget.height())<br>
<br>
but that didn&#39;t work either.<br>
<br>
If I make 150 pixels the maximum width of the dock window, then it is the width I \
want it, but it can&#39;t be made any wider. I don&#39;t want to make 150 pixels the \
maximum (or minimum) width of the pane, just the default width. It also seems like \
the policy that I would want for QSizePolicy.<u></u>setHorizontalPolicy() is \
QSizePolicy.Preferred, which is already the default one.<br> \
</blockquote><div><br></div><div>You could try an initial resizeColumnToContents() \
call which should make column as wide as its contents are. This is of course slower \
if you have lots of data. There&#39;s also ways to set the column width explicitly \
which should also make the treeview smaller.</div> \
<div><br></div><div>Andreas</div></div></div></div>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic