[Interest] QGraphicsItem constructor access to scene

2020-06-08 Thread Nicholas Yue
Hi,

  During the constructor phase of my QGraphicsItem derive class, I need to
perform some QFont related information. The font information may be
obtained via scene object but my study of the constructor stage is that it
is not initialized yet.

  The derived class is added to the scene via the addItem() call.

  Is there another way to access the scene in a QGraphicsItem constructor ?

  For now, I am passing the scene object explicitly

class NodeItem(QtWidgets.QGraphicsItem):

def __init__(self, name, attribues, scene):
'''scene is only required because we need to query the font
'''
super(NodeItem, self).__init__()

  Q : Does my need to use scene in the constructor indicates that my class
was not designed properly?

  Q : Are there other ways to obtain the font information in the
constructor other than ?
font = scene.property('font')
fm = QtGui.QFontMetrics(font)

Cheers
-- 
Nicholas Yue
Graphics - Arnold, Alembic, RenderMan, OpenGL, HDF5
Custom Dev - C++ porting, OSX, Linux, Windows
http://au.linkedin.com/in/nicholasyue
https://vimeo.com/channels/naiadtools
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] how to get 3 pixel focus ring?

2020-06-08 Thread David M. Cotter
this is an enlightening conversation, so thanks for chiming in

> One thing to be aware of when using QMacStyle or QWindowsStyle
well, but, see, i don't want to use those

i want to use stylesheets, like this:

"::focus { border: 3px solid #color }"

not related to mac or windows

and this is in fact what kTest_PARENT_STYLE is using

my question is: wouldn't you expect that to work fine on BOTH widgets (tree and 
table) and NOT JUST ONE? (on mac)

is this, in fact, a bug?

> On Windows, when I ran your test, it looks like you are getting the standard 
> Windows dotted-line focus ring. Usually it's a bit inset from the edges of 
> the edit box, though. Once again, QWindowsStyle is giving you the Windows 
> look, and that's it

and for windows, is there a method i can use such that the "3px" is not ignored 
(it's always set to 1px regardless of the value i set)

is that a bug too?

do you mean QWindowsStyle is like some kindof default that's going on under the 
hood that overrides my "3px" setting?

is there ANY way i can maybe with a custom QFrame or QWidget maybe draw a 
custom border like i'm using for kTest_PARENT_STYLE instead of using style 
sheet, just literally custom draw it? maybe that would be the quickest route to 
my goal.

(again i'm not here to get feedback on the WORTHINESS of my goal, just for 
technical details on how to achieve it, thanks)

-dave

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] how do I load massive table views instantly?

2020-06-08 Thread Scott Bloom
BTW.. I missed that you are using QSRTM, since you are use QSRTM, you shouldn’t 
need to use any proxy model.

Simply use the setFilter and setOrder methods.  The setOrder should be handled 
automatically by your view when you set the model, and enable sorting on the 
view.

Scott

-Original Message-
From: Interest  On Behalf Of David M. Cotter
Sent: Monday, June 8, 2020 4:43 PM
To: interest@qt-project.org
Subject: Re: [Interest] how do I load massive table views instantly?

right okay so my source model class is QSqlRelationalTableModel, no subclass.

does this answer your question?

sorry i'm still learning about this stuff.

now that you know that, is it easier to answer my original question?


> On Jun 8, 2020, at 1:37 PM, Francis Herne  wrote:
> 
> On Friday, 5 June 2020 17:23:37 BST David M. Cotter wrote:
> What table view are you talking about, specifically?
 
 QTableView with QSortFilterProxyModel
>>> 
>>> What is the model _behind_ QSFPM?
>> 
>> i'm trying to understand your question. i'm not sure what you mean, 
>> cuz i'm not the SQLite dev what i know is that each song has a couple 
>> dozen bits of data (name, artist, album, several file paths, rating, 
>> duration etc etc) besides that, what are you asking?=
> 
> QSortFilterProxyModel is a *proxy* that makes other models sortable.  
> it only works when its `sourceModel` property is set to an instance of 
> a different model class that actually contains the data.

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] how do I load massive table views instantly?

2020-06-08 Thread Scott Bloom
One thing I have found in years past, sorting via a proxy when dealing with sql 
models, is a bad idea.

All models, have the "fetch" functionality.  Allowing the application, to load 
the data incrementally.. This is critical for large tables.  Yes, your scroll 
bars are "screwed up", but in the end, you can load very large databases, very 
quickly. Your limited by the SQL engine/server time to return the first 250 
records, rather than the millions in the full table .

But, if you use a proxy model, the SQL model is going to have to fully load the 
table, then sort it.  This is equivalent to selecting from the table, and 
sorting based on a key that isn’t indexed.

You wouldn’t want a "sorted" table to change the order as you scrolled down.  
Ie, if the first 250 records sorted by last name didn’t have an A in the 
records, and 251 did, you wouldn’t want that record to pop to the top.

A much better approach, I have used in the past, is to have the SQL model, 
change the select statement based on the sort column requested.

Ie, select * from table order by column_name asc

Is much faster, and a more effective method of sorting the table than select * 
from table, and then sorting the complete table.  For small tables, honestly 
you might not see any difference, but for big tables the difference can be 
dramatic.

Scott


-Original Message-
From: Interest  On Behalf Of David M. Cotter
Sent: Monday, June 8, 2020 4:43 PM
To: interest@qt-project.org
Subject: Re: [Interest] how do I load massive table views instantly?

right okay so my source model class is QSqlRelationalTableModel, no subclass.

does this answer your question?

sorry i'm still learning about this stuff.

now that you know that, is it easier to answer my original question?


> On Jun 8, 2020, at 1:37 PM, Francis Herne  wrote:
> 
> On Friday, 5 June 2020 17:23:37 BST David M. Cotter wrote:
> What table view are you talking about, specifically?
 
 QTableView with QSortFilterProxyModel
>>> 
>>> What is the model _behind_ QSFPM?
>> 
>> i'm trying to understand your question. i'm not sure what you mean, 
>> cuz i'm not the SQLite dev what i know is that each song has a couple 
>> dozen bits of data (name, artist, album, several file paths, rating, 
>> duration etc etc) besides that, what are you asking?=
> 
> QSortFilterProxyModel is a *proxy* that makes other models sortable.  
> it only works when its `sourceModel` property is set to an instance of 
> a different model class that actually contains the data.

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] how do I load massive table views instantly?

2020-06-08 Thread David M. Cotter
right okay so my source model class is QSqlRelationalTableModel, no subclass.

does this answer your question?

sorry i'm still learning about this stuff.

now that you know that, is it easier to answer my original question?


> On Jun 8, 2020, at 1:37 PM, Francis Herne  wrote:
> 
> On Friday, 5 June 2020 17:23:37 BST David M. Cotter wrote:
> What table view are you talking about, specifically?
 
 QTableView with QSortFilterProxyModel
>>> 
>>> What is the model _behind_ QSFPM?
>> 
>> i'm trying to understand your question. i'm not sure what you mean, cuz i'm
>> not the SQLite dev what i know is that each song has a couple dozen bits of
>> data (name, artist, album, several file paths, rating, duration etc etc)
>> besides that, what are you asking?=
> 
> QSortFilterProxyModel is a *proxy* that makes other models sortable.  it only 
> works when its `sourceModel` property is set to an instance of a different 
> model class that actually contains the data.

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] how to get 3 pixel focus ring?

2020-06-08 Thread John Weeks
One thing to be aware of when using QMacStyle or QWindowsStyle is that they are 
trying to emulate the Macintosh or Windows mandated look. The blue focus ring 
is a Macintosh thing, and like many things Apple, it comes in one size. The 
width of the blue line is mandated.

On Windows, when I ran your test, it looks like you are getting the standard 
Windows dotted-line focus ring. Usually it's a bit inset from the edges of the 
edit box, though. Once again, QWindowsStyle is giving you the Windows look, and 
that's it.

You might try Fusion style, we have found that the look isn't bad, but it 
doesn't look like either Windows or Macintosh.

Hope this helps

-John Weeks

> On Jun 8, 2020, at 12:48 PM, David M. Cotter  wrote:
> 
> can anyone explain why tree view looks fine but  table view only has 1 pixel?
> 
> @adam did you download the example project? it's trivial to run and you can 
> test several implementations.  which impl would be used with your suggestion 
> of PM_FocusFrame margins?
> and do you have maybe example code to implement your suggestion?  
> 
> part of my question is: is this a bug in Qt ? because IMHO "QFocusFrame" 
> should "just work", and why does it NOT?
> 
> or setting the style to 3 px should "just work" and why does it NOT work but 
> only for certain widgets?
> 
> you'd think that QFocusFrame would *manage* the clipping properly?
> 
> or the doc should be more clear, with sample code, cuz i've read the doc 
> several times and am no further along :(
> 
> any help would be greatly appreciated!  if you like karaoke, i have an app 
> for you ;-)
> 
> -dave
> 
>> On Jun 8, 2020, at 5:18 AM, Adam Light  wrote:
>> 
>> On Sun, Jun 7, 2020 at 2:21 PM David M. Cotter  wrote:
>> i have an example project (see below), that tries 6 different 
>> implementations, attempts to make the focus ring 3 pix wide. None of them 
>> work on windows, and only one of them PARTIALLY works on mac. What i want is 
>> the style you get around a text edit on mac, but i want that style on ALL 
>> widgets, and i want it on windows too.
>> 
>> anyone have any idea how i can accomplish this?
>> 
>> It might be as simple as returning a different value for 
>> QStyle::PM_FocusFrameHMargin and QStyle::PM_FocusFrameVMargin in a 
>> QStyle::pixelMetric or QProxyStyle::pixelMetric implementaton. If you're 
>> using one of the standard styles then it's pretty simple to create and use a 
>> QProxyStyle class to tweak pixel metrics and other aspects of the style.
>> 
>> If that doesn't work you may be able to reimplement 
>> Q[Proxy]Style::drawControl for element QStyle::CE_FocusFrame and handle the 
>> drawing of the focus frame itself.
>> 
>> One thing to watch out for is that making QStyle::PM_FocusFrameHMargin and 
>> QStyle::PM_FocusFrameVMargin larger than default can result in the focus 
>> frame getting clipped in some situations. We see this using persistent 
>> editors in itemviews sometimes, and I think we also sometimes see this when 
>> certain widgets are in splitters.
>> 
>> Adam
> 
> ___
> Interest mailing list
> Interest@qt-project.org
> https://lists.qt-project.org/listinfo/interest



-John

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] how do I load massive table views instantly?

2020-06-08 Thread Francis Herne
On Friday, 5 June 2020 17:23:37 BST David M. Cotter wrote:
> >>> What table view are you talking about, specifically?
> >> 
> >> QTableView with QSortFilterProxyModel
> > 
> > What is the model _behind_ QSFPM?
> 
> i'm trying to understand your question. i'm not sure what you mean, cuz i'm
> not the SQLite dev what i know is that each song has a couple dozen bits of
> data (name, artist, album, several file paths, rating, duration etc etc)
> besides that, what are you asking?=

QSortFilterProxyModel is a *proxy* that makes other models sortable.  it only 
works when its `sourceModel` property is set to an instance of a different 
model class that actually contains the data.


___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] how to get 3 pixel focus ring?

2020-06-08 Thread David M. Cotter
can anyone explain why tree view looks fine but  table view only has 1 pixel?

@adam did you download the example project? it's trivial to run and you can 
test several implementations.  which impl would be used with your suggestion of 
PM_FocusFrame margins?
and do you have maybe example code to implement your suggestion?  

part of my question is: is this a bug in Qt ? because IMHO "QFocusFrame" should 
"just work", and why does it NOT?

or setting the style to 3 px should "just work" and why does it NOT work but 
only for certain widgets?

you'd think that QFocusFrame would *manage* the clipping properly?

or the doc should be more clear, with sample code, cuz i've read the doc 
several times and am no further along :(

any help would be greatly appreciated!  if you like karaoke, i have an app for 
you ;-)

-dave

> On Jun 8, 2020, at 5:18 AM, Adam Light  wrote:
> 
> On Sun, Jun 7, 2020 at 2:21 PM David M. Cotter  > wrote:
> i have an example project (see below), that tries 6 different 
> implementations, attempts to make the focus ring 3 pix wide. None of them 
> work on windows, and only one of them PARTIALLY works on mac. What i want is 
> the style you get around a text edit on mac, but i want that style on ALL 
> widgets, and i want it on windows too.
> 
> anyone have any idea how i can accomplish this?
> 
> It might be as simple as returning a different value for 
> QStyle::PM_FocusFrameHMargin and QStyle::PM_FocusFrameVMargin in a 
> QStyle::pixelMetric or QProxyStyle::pixelMetric implementaton. If you're 
> using one of the standard styles then it's pretty simple to create and use a 
> QProxyStyle class to tweak pixel metrics and other aspects of the style.
> 
> If that doesn't work you may be able to reimplement 
> Q[Proxy]Style::drawControl for element QStyle::CE_FocusFrame and handle the 
> drawing of the focus frame itself.
> 
> One thing to watch out for is that making QStyle::PM_FocusFrameHMargin and 
> QStyle::PM_FocusFrameVMargin larger than default can result in the focus 
> frame getting clipped in some situations. We see this using persistent 
> editors in itemviews sometimes, and I think we also sometimes see this when 
> certain widgets are in splitters.
> 
> Adam

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] how to get 3 pixel focus ring?

2020-06-08 Thread Adam Light
On Sun, Jun 7, 2020 at 2:21 PM David M. Cotter  wrote:

> i have an example project (see below), that tries 6 different
> implementations, attempts to make the focus ring 3 pix wide. None of them
> work on windows, and only one of them PARTIALLY works on mac. What i want
> is the style you get around a text edit on mac, but i want that style on
> ALL widgets, and i want it on windows too.
>
> anyone have any idea how i can accomplish this?
>

It might be as simple as returning a different value
for QStyle::PM_FocusFrameHMargin and QStyle::PM_FocusFrameVMargin in a
QStyle::pixelMetric or QProxyStyle::pixelMetric implementaton. If you're
using one of the standard styles then it's pretty simple to create and use
a QProxyStyle class to tweak pixel metrics and other aspects of the style.

If that doesn't work you may be able to reimplement
Q[Proxy]Style::drawControl for element QStyle::CE_FocusFrame and handle the
drawing of the focus frame itself.

One thing to watch out for is that making QStyle::PM_FocusFrameHMargin and
QStyle::PM_FocusFrameVMargin larger than default can result in the focus
frame getting clipped in some situations. We see this using persistent
editors in itemviews sometimes, and I think we also sometimes see this when
certain widgets are in splitters.

Adam
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest