<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 9/7/21 11:21 PM, Maurizio Berti
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAPn+-XTxRUXg_rg9H0W4noQ758g22duW4CzC4zGqefNKZe0jNw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">Il giorno mar 7 set 2021 alle ore 13:52
paparucino <<a href="mailto:paparucino@gmail.com"
moz-do-not-send="true">paparucino@gmail.com</a>> ha
scritto:</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px
0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div> <font face="monospace">One of the first
attempts I made was just to insert QMainWindow but
since there is already a QMainWindow (the general
of the project) every time I selected a month to
view the script it triggered a script that had
nothing to do with what was requested. QtObject is
just the last of my attempts and it stayed there
when I wrote the email.</font></div>
</blockquote>
<div><br>
</div>
<div>If I understand what you wrote, that happens
because you called setupUi on self, as explained in my
previous message.<br>
If you want to create a *new* window with the given
parameters, you should use a new QMainWindow instance
(or use a class as in my examples)</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<p>Which is what I'm doing besides going crazy :)</p>
<br>
<blockquote type="cite"
cite="mid:CAPn+-XTxRUXg_rg9H0W4noQ758g22duW4CzC4zGqefNKZe0jNw@mail.gmail.com">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_quote">
<div>- whenever you have to change even the slightest
aspect of the UI, you have to integrate those changes
by merging your existing code, which is a painful
process that almost always leads to bugs and lots of
headaches;</div>
<div>- it's *not* intended for modification, as it's
just a "translation" of the UI xml into python code,
and should always behave exactly like using the loadUi
function with the same source UI file;<br>
</div>
<div>
<div>- modification usually leads to unexpected
behavior if you don't really know what you're doing
and how those files work;<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
I never edit the ui file. I keep it as a base and eventually I
create many .py files depending on how the debug goes. I know that
it is confusing and that I fill the dir with files but sometimes I
start from an idea and as everything evolves I can change my mind
and therefore I have a base plus a certain series of more or less
functional back ups<br>
<blockquote type="cite"
cite="mid:CAPn+-XTxRUXg_rg9H0W4noQ758g22duW4CzC4zGqefNKZe0jNw@mail.gmail.com">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_quote">
<div>
<div>"Linking to the rest of the project" then means
that you start from that "template" and integrate it
with the actual, final program logic.</div>
</div>
<div>Let's suppose your program has to show an undefined
number of tables based on the contents of a database.
This probably means that you should create a UI that
has *no* table at all, and only has a placeholder or
container that will then be used to put those tables
into. In your program you will then actually create
those tables according to your needs.</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
The example is perfect, but if I don't have an entry point for my
tables in the ui-> py file, I don't know where to start. I
created a ui file with scrollArea containing a number of tables,
transformed it into py, I "analyzed the code, I deleted all the
tables by inserting mine, with the necessary changes. Result: I get
what I expect. Then the problems begin. .<br>
<blockquote type="cite"
cite="mid:CAPn+-XTxRUXg_rg9H0W4noQ758g22duW4CzC4zGqefNKZe0jNw@mail.gmail.com">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px
0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div>
<p> </p>
<p>A stackoverflow user advised me to use this
system because I had problems in the first two
rows of the tables that would then end up in the
infamous scrollArea (see:
<a
href="https://stackoverflow.com/questions/65493443/qtablewidget-column-span-doesnt-resize-correctly"
target="_blank" moz-do-not-send="true">https://stackoverflow.com/questions/65493443/qtablewidget-column-span-doesnt-resize-correctly</a>)<br>
</p>
</div>
</blockquote>
<div>I remember that question (I pointed you out to the
bug report, which seems resolved but only since
Qt6.1).</div>
<div>While the proposed answer works, a more appropriate
and consistent solution could be to override
sizeHintForColumn. The following is a very basic
implementation, as it doesn't consider more extended
aspects and isn't suitable for very large models.</div>
<div><br>
</div>
<div>
<div><font face="monospace">class
TableWidget(QTableWidget):</font></div>
<div><font face="monospace"> def
sizeHintForColumn(self, column):</font></div>
#<br>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<p>Thank you, later will give it a try. Actually I need to fill the
scrollArea with my tables.</p>
<p>Now I try to prepare a reproducible code because I can't get out
of it</p>
<p><br>
</p>
<p>Regards,</p>
<p>paparucino<br>
</p>
</body>
</html>