Re: [Interest] [External] QGraphicsProxyWidget not honoring embedded widget's palette

2022-02-21 Thread Murphy, Sean
> If, however, I move that same widget onto a QGraphicsScene via
> fooWidget* foo = new fooWidget();
> foo->setFooData(data);
> QGraphicsProxyWidget* proxy = scene->addWidget(foo) The fooWidget is
> properly added to the scene, all of its child widgets' text values are 
> correctly
> updated based on whatever is in "data", BUT the widget background colors
> are not updated - they are just the default values as if I hadn't attempted to
> change the palette.
> 
> Any way for me to get QGraphicsProxyWidget to honor the embedded
> widget's palette? Using Qt 5.15.2 if that matters...

Quick self-update here, it looks like it has something to do with QLabels that
I had modified to have a frameShape of StyledPanel. If I switch those back to 
having the default frameShape of NoFrame, then they are painted  correctly 
regardless of whether they are out in my MainWindow hierarchy, or whether 
they are wrapped inside of a QGraphicsProxyWidget, although now I've lost 
the frame border that I wanted. Looks like I'll just have to write a custom 
stylesheet 
that updates based on the fooData parameters.

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


[Interest] QGraphicsProxyWidget not honoring embedded widget's palette

2022-02-21 Thread Murphy, Sean
I'm attempting to add a custom widget to a QGraphicsScene and I'm having 
some trouble with the palette settings. 

1. I've got a custom widget class, say "fooWidget" which is a composite widget 
made up of a bunch of different child widgets (QLabels, QRadioButtons, 
etc.). 
2. It has a setFooData(const fooData& data) function which populates all the 
label 
text, radio buttons, etc. based off from the parameters in "data". Part of 
populating
everything includes changing the background colors of some of the widgets 
by 
modifying the QPalette for those specific widgets. 

This works perfectly if I instantiate the fooWidget anywhere under my 
MainWindow 
widget hierarchy - the child widgets' text are all set correctly AND their 
background colors
are filled in properly.

If, however, I move that same widget onto a QGraphicsScene via 
fooWidget* foo = new fooWidget();
foo->setFooData(data);
QGraphicsProxyWidget* proxy = scene->addWidget(foo)
The fooWidget is properly added to the scene, all of its child widgets' text 
values are 
correctly updated based on whatever is in "data", BUT the widget background 
colors are 
not updated - they are just the default values as if I hadn't attempted to 
change the palette.

Any way for me to get QGraphicsProxyWidget to honor the embedded widget's 
palette? Using
Qt 5.15.2 if that matters...

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


Re: [Interest] [External]Re: How to get QtConcurrent to do what I want?

2022-02-01 Thread Murphy, Sean
> On Tuesday, 1 February 2022 11:12:29 PST Murphy, Sean wrote:
> > So if I understand you correctly, instantiating 60,000 of them when
> > you really only need one would be considered Not Advised?!?!
> 
> Correct.
> 
> I find it hard to believe you have a valid use-case for 60,000 deterministic
> pseudo-random generators, though.

I definitely didn't! But that didn't stop me from doing it...
Sean
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] [External]Re: How to get QtConcurrent to do what I want?

2022-02-01 Thread Murphy, Sean
> On Tuesday, 1 February 2022 08:30:52 PST Murphy, Sean wrote:
> > I just made that switch - removed the QRandomGenerator member
> variable
> > From the tile class, and calling
> > QRandomGenerator::global()->bounded(min,
> > max). Now creating  + assigning each tile plummeted from 18 seconds to
> > 15 milliseconds.
> 
> Unfortunately, QRNG has now as ABI requirement that it uses the Mersenne
> twister. That means it's 624 * 4 bytes in size (plus overhead) and must seed
> that thing, which is non-trivial math.

So if I understand you correctly, instantiating 60,000 of them when you really 
only need one would be considered Not Advised?!?!

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


Re: [Interest] [External]Re: How to get QtConcurrent to do what I want?

2022-02-01 Thread Murphy, Sean
> Depending on your QFuture setup, you could monitor each tile, and when it
> completes, update the min max...

I think from the testing I did yesterday, and this comment from 
https://doc.qt.io/qt-5/qfuturewatcher.html prevents you from knowing WHICH
result is ready if your map function returns void:

"QFutureWatcher is specialized to not contain any of the result fetching 
functions. Any QFuture can be watched by a QFutureWatcher as well. 
This is useful if only status or progress information is needed; not the actual 
result data."

One of my early go arounds yesterday had me connecting the 
QFutureWatcher::resultReadyAt(int index) from the watcher that was 
monitoring 
the tile::load() call to a slot in my tileManager class. That slot was never 
called. If I 
used the QFutureWatcher::progressValueChanged(int progressValue) signal 
instead, the slot was called as each tile completed. But the issue there is 
that you 
only know HOW MANY have completed, not WHICH ONES. 

So from what I could tell, if you want to work with the result of an individual 
item right 
when it comes in, the function you pass as the map function has to have a 
non-void return 
type so that you aren't instantiating a QFutureWatcher which doesn't fire 
those signals, 
but instead instantiate a QFutureWatcher and then you can use the 
resultReadyAt(int index)

> Passing the manager to each tile, and when the tile is finished update the
> manager with the tiles value.  Then a simple mutex should allow you to not
> collide.  No signals, just a simple function call.

Oh man, my head is already bursting with the QtConcurrent and QFuture stuff, 
now you want to 
toss QMutex at me too?!?! 
 
> When the future watcher says all tiles are done, you will also have the
> min/max computed at that point, so you can kick off phase 2.
> 
> While I love the signal slot for "generic, I don’t know who needs this
> information" type design. Sometimes the cost/overhead of being a qobject
> and sending the signal, especially when it’s a very discrete "signal" and not
> generic in any means, it can be overkill.
> 
> To me, the manager you have doesn’t need to know "is a tile finished", ie a
> generic signal.  But rather what Is the min max of the tile when finished a
> specific signal.  For that level, a simple function works.

From where I'm at right now, I think that can be accomplished by changing my 
loadTile function from:
void loadTile(tile )
{
t.load();
}

QPair loadTile(tile )
{
t.load();
return t.getMinMax();
}

Then change to QtConcurrent::mapped() instead of map() since my future type 
is now QPair and then I can connect the 
QFutureWatcher>::resultReadyAt(int index) to a slot that 
updates the global min/max.

Although as I'm reading through everything, this also might the point to use 
QtConcurrent::mappedReduced(). So many options to choose from...

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


Re: [Interest] [External]Re: How to get QtConcurrent to do what I want?

2022-02-01 Thread Murphy, Sean
>   that definitely does.
> 
> Of course I wonder if you had removed that, but left in the QObject etc
> etc, what would it have been.  Likely, not much worse than 15ms.

Yep, once I removed the random generator object, I had the same thought: 
"could I go back to QObject?!?!", but as you mention, I don't think there's any 
reason for me to do that, unless I can think of a reason that I need to provide 
some sort of signal down at a tile level beyond just completion progress (since 
QFutureWatcher can handle the progress part). 

The only potential signal that comes to mind is between the tile::load() and 
tile::remap() 
steps I do need to know the min/max raw data values to compute what the remap 
parameters are. Currently I have to wait for the loadFutureWatcher to report it 
is 
finished, then I take a pass through every tile to calculate the global min/max 
values, 
then I can kick off the remap process with those parameters in hand. If the 
tile was 
an QObject and it emitted a signal to relay that information back then the 
global 
min/max is getting updated as each tile completes its first step, which means 
as soon 
as the last tile finishes, I'm good to go with the remap step instead of taking 
that pass 
through all the tiles to determine the global min/max.

But I could also accomplish the same thing by modifying the loadTIle function 
that is passed to 
QtConcurrent to return a QPair instead of returning void like 
it currently is 
Does. Then I would connect the future watcher's resultReadyAt(int index) signal 
to a slot 
in my tile manager that accomplishes the same thing, without making my tile 
class 
inherit from QObject.

> 
> Why? IMO, Qt wouldn’t be what it is today, if simply allocating 60k QObjects
> and connecting a signal to them too that long.
> 
> But I think the overall architecture of what you have now, is MUCH better
> and will scale to a more complex "actually do the work" system much better
> than the other.

I think I'm happy with it as a proof-of-concept design as I have it now - or at 
least once I 
replace the placeholder delays with the code that actually works on the data 
file. After that, 
I want to also implement the idea Konstantin suggested of just dividing the 
original image up into 
QThread::idealThreadCount() blocks and then compare the results on actual data 
and see which performs better. I'm guessing it'll be the latter since on my 
idealThreadCount() == 8 
system, there's probably way less overhead in creating 8 things that do the 
work than 60,000+. 
Especially since the 60,000 items are still going to be funneled through 8 
threads anyways.

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


Re: [Interest] [External]Re: How to get QtConcurrent to do what I want?

2022-02-01 Thread Murphy, Sean
> Subject: RE: [Interest] [External]Re: How to get QtConcurrent to do what I
> want?
> 
> Something seems off.
> 
> But without looking at the actual code that is allocation 60k tiles and the
> constructor itself, it just seems like a very expensive construction if the
> "new" + "moving a pointer" is taking 3ms each.

I finally figured that part out. 

Since this is just test code and doesn't do any real work yet, I was putting a 
delays in 
tile::load() and tile::remap() just to simulate that those functions take time 
to execute. 
To create a little realism, I was randomizing the amount of that delay instead 
of using a 
fixed delay. To accomplish that, I mistakenly added a QRandomGenerator as a 
member 
variable of the tile class, instead of just calling 
QRandomGenerator::global()->bounded(min, max)
in the tile::load() and tile::remap()functions. Each tile certainly doesn't 
need its own 
uniquely seed random number sequence...

I just made that switch - removed the QRandomGenerator member variable 
>From the tile class, and calling QRandomGenerator::global()->bounded(min, 
>max). Now 
creating  + assigning each tile plummeted from 18 seconds to 15 milliseconds.

That seems pretty acceptable to me...

Sean

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


Re: [Interest] [External]Re: How to get QtConcurrent to do what I want?

2022-02-01 Thread Murphy, Sean
> Not knowing if a partial value makes any sense to your system.
> Qt::Concurrent::mappedReduced might make more sense, if its purely a
> speedup you are looking for, and not a "keep the GUI alive during it" possibly
> blockingMappedReduced.

I don't think mappedReduced would help me until after the remapping step 
when I want to assemble the individual tiles into a QImage - although since the 
ultimate destination for the image is inside a QGraphicsView, I'm tempted to 
just 
leave it as individual tiles, but I'm not there yet as far as testing.

Regarding the keep GUI alive portion, my tileManager is already running in a 
separate thread from the UI thread, so I do have the option of making blocking 
calls
in the tileManager class with the exception that I do need to fire progress 
signals out 
of tileManager back to MainWindow to provide progress to the user

> 
> If you need the gui, setting up a qfuturewatcher on the results of the
> mapped call, would be my approach
> 
> QFutureWatcher< XXX > watcher;
> connect( , , manager, );
> 
> auto future = QtConcurrent::mapReduced(tiles, processTile, mergeFunction)
> watcher.setFuture( future );

I actually spent yesterday refactoring the tileManager class as you've just 
described, 
as well as changing out the tile class to no longer inherit from QObject. I've 
got a couple 
more things I want to try/clean up today but I still seem to be having trouble 
speeding 
up the allocation & assignment of the tiles themselves.

As my code currently stands, I now have to vectors, each of which will have 
60,000 items 
in them once they're populated:
  QVector mTileIndices;
  QList mTiles;

The mTileIndices vector is implementing Andrei's idea of quickly generating a 
list of unique tile 
indices, which can then be fed to a QtConcurrent::map() call to create & 
uniquely assign the 
tile items in parallel. The " mTiles " vector is obviously the tiles that will 
do the 
work.

As I build the vectors up, these are the timings I get:
  1. resizing tile index vector to 6 took 0.1514 ms
  a. This is just calling QVector::resize(6) on the ID. This takes 
less than a 
   millisecond, so no complaints here.
  2. allocated 6 indices in 0.0207 ms
  a. This is calling std::iota(mTileIndices.begin(), mTileIndices.end(), 
0). Also takes less than 
  a millisecond, still no complaints
  3. assigning 6 tiles took 18087.1 ms
  a. This timing is the result of QtConcurrent::mapped(mTiles, initTile) 
where the initTile 
  function takes in an integer from mTileIndices, and calls the tile 
constructor using the 
  combination of the tile index and tile size to do the assignment. The 
assigned tiles end 
  up in the mTiles
  b. This step takes 18 seconds, which seems excessive to me and I'd love 
to continue to 
   reduce that time.
  4. load finished in 37507.1 ms
  a. this is calling tile::load() on each tile. Right now that is just a 
dummy function that calls 
  msleep for a random amount milliseconds to simulate doing the actual 
work
  5. remapping 6 tiles took 48519.3 ms
  b. this is calling tile::remap() on each tile. Right now that is just a 
dummy function that 
  calls msleep for a random amount milliseconds to simulate doing the 
actual work

So the only step in this process that still bothers me is step 3 - creating and 
assigning each tile 
object takes 18 seconds. I log the total time by each tile spent in steps 4 & 5 
and compare how 
long steps 4 & 5 actually take vs. the sum of how long each tile spent sleep 
and I routinely get
a speedup factor of about 7.5. QThread::idealThreadCount() reports 8 on my 
machine, so I think
I'm getting what I should expect from those steps on this machine.

I'm not sure what else to try at this point. One thing I was thinking about 
measuring is that even 
though my tile class no longer inherits from QObject, it still is a class with 
a constructor and some 
getter functions. And when I look at the combination of steps 1 & 2 where I 
both resize a vector 
of integers AND assign each one a unique ID in less than a millisecond total, 
but then it takes 
me 18 seconds to create and assign each tile, I keep wondering if there isn't 
room for 
improvement there still?

And as I was typing this whole thing up, Konstantin gave me a different 
approach that I'll probably 
pursue, but I would like to better understand how to solve the question of "if 
you absolutely need 
to have a lot of items (whatever type an "item" needs to be), what's the right 
design approach to 
be able to create and populate them quickly..."

Sean

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


Re: [Interest] [External]Re: How to get QtConcurrent to do what I want?

2022-02-01 Thread Murphy, Sean
> > What's the significance of the tiles? As far as I can tell from your
> requirements, you don't care about
> > the "true geometry" of the data.
> 
> Either I'm understanding what you mean by "true geometry", or this

Oops! This was supposed to say "Either I'm NOT understanding..."

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


Re: [Interest] [External]Re: How to get QtConcurrent to do what I want?

2022-02-01 Thread Murphy, Sean
> On Mon, Jan 31, 2022 at 7:15 PM Murphy, Sean 
> <mailto:sean.mur...@centauricorp.com> wrote:
> >   1. Creating 60,000 QObjects in a single thread appears to be slow  
> [...]
>
> Ehm, maybe I'm not understanding something, but why do you need objects to 
> begin with?

I do need to report progress back to the UI and I mistakenly thought I needed 
to have 
each tile inherit from QObject to provide that functionality. After reading up 
a bit more about 
QFuture and QFutureWatcher and then refactoring yesterday to use those classes, 
as of the 
moment, my tile class no longer inherits from anything, and I'm able to use 
signals from 
QFutureWatcher to relay progress back to the UI. 

> The actual loop is this:
>    // generate each tile with its assignment
> [snip]
>
> What's the significance of the tiles? As far as I can tell from your 
> requirements, you don't care about
> the "true geometry" of the data.

Either I'm understanding what you mean by "true geometry", or this assumption 
is at least partially incorrect. 
Looking back on my list of requirements I've posted, I left off the last step: 

  At the end of all this processing, I do need to produce an onscreen image to 
the user. 

So any way I slice up the work that needs to be done using threads, once they 
are all finished, I do need to 
know what chunk of the original image each thread was working on to know where 
place its normalized pixels 
in what I display to the user.

> At least to me it seems you want something like (pseudo algorithm):
>
> 1) Start QThread::idealThreadCount threads (QThread::create<> / std::thread)
> 2) Each thread works on "total samples" / QThread::idealThreadCount buffers 
> that are completely independent.
> 2.1) Each thread goes through each sample from a partially mapped (from the 
> file) buffer, takes the min/max to get the dynamic range
> 2.2) Sync the threads to get the global min/max
> 2.3) Go through each of the buffers a second time to normalize the dynamic 
> range (again no tiles involved, just samples)
> 3) Done.

I think this is an preferable approach to what I was attempting, and I'm glad 
you suggested it. This being my first attempt at this, 
I naively started from asking "what seems like it would be a reasonable tile 
size?", arbitrarily thought "256 pixels square" and worked 
backwards from there, which is how I got into this mindset of "I might have 
60,000+ tiles to deal with". Your approach starts from 
what now appears to me a much better thought of "what's the ideal number of 
threads for your machine? Don't bother creating 
more threads than that because you're not going to benefit by having more" and 
then working forward from there.

> Note: As each thread works on its own piece of data in both cases there's no 
> sync required at any one point - 
> you just read/write different parts of the same thing. Which is true both for 
> when you load/write from/to a file 
> and from/to memory.

Not sure if I quite understand what you meant by this note? There is the sync 
you pointed out as your step 2.2, and then since I need to 
form the results into an onscreen image (most likely a QGraphicsPixmapItem, 
etc.) there's another sync at your step 3 before I can make
the final onscreen image. Otherwise I think I understand and prefer your 
concept to what I was doing.

Thanks again for your help! Now to test this out in practice... 
Sean

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


Re: [Interest] [External]Re: How to get QtConcurrent to do what I want?

2022-01-31 Thread Murphy, Sean
Thanks for the reply, Scott. My responses below:

> Couple things I would try.
> 
> First, preallocate the size of the vector, or use a list if you don't need 
> random access into it.  

I had attempted this before my original post. My sequence of attempts before I 
posted went 
like this:
  1. Started with QList>, and calling list.append() to 
populate. 
Noticed this was somewhat slow 
  2. Switched to QVector>, still calling list.append() to 
see if that made 
any difference. It didn't.
  3. Realized that calling append() on a QVector could be slow as the vector 
keeps growing 
and is forced to reallocate, so I added a QVector::reserve() call 
beforehand to prevent that. 
Still made no appreciable difference

I neglected to add the reserve() call to the code I posted here, so that's on 
me for not painting 
the full picture - more on that below. From the attempts above it didn't seem 
like the type of 
container, nor how I build it up were the problem.

> Second, just send, pos, size into the tile.  Only save the values in the 
> constrctor. When the 
> worker thread kicks off on a tile, then initialize it and do any computation. 
>  This includes the 
> allocation of the submatrix.

I think this is what I'm already doing, correct? My tile constructor only 
assigns those values and 
does nothing else (ACTUAL code below, not edited pseudocode like the previous 
email):
tile::tile(int id, QPoint pos, int size, QObject *parent) : QObject(parent),
mID(id),
mPos(pos),
mSize(size)
{
}

One thing to note here that I didn't include in my previous email, and as I 
keep investigating is 
starting to look like the real cause of slow allocation/assignment loop, my 
tile class inherits 
from QObject. My original thought was that I wanted to be able to use signals 
to monitor what's 
going on inside of the tile class, but I'm beginning to rethink whether I 
really need that at all, 
especially for the hassles that it causes: 
  1. Creating 60,000 QObjects in a single thread appears to be slow  
a. I've since tested creating a 60,000 item QVector AND looping 
through it assigning each
item the value 0-5, and using QElapsedTimer to measure that takes 
0.3 ms vs. 5 seconds or
so to execute my current loop
  2. Since QObject doesn't have a copy constructor, but QtConcurrent expects a 
container of type
T items not T* items, I chose to wrap my tile* within a QSharedPointer to 
get everything to work out. 
As you point out below, I may have chosen the wrong smart pointer type, 
since I'm not really 
sharing the pointer around, but my goal there was to satisfy what 
QtConcurrent expects of the 
container you pass in to the map() function

>
> Also, does it need to be a shared pointer?  Its clear who owns the pointers, 
> they aren't being 
> "shared" as much as use.  For me, I only use shared pointers, when multiple 
> objects can 
> "own" the pointer.  In this case, the tile manager owns the tiles.

>From this comment, I'm realizing that posting pseudocode/stripped down code 
>previously was 
a mistake as it was only painting a partial picture. The actual loop is this:
// generate each tile with its assignment
for(int i=0; i < nTiles.height(); ++i)
{
for(int j=0; j < nTiles.width(); ++j)
{
int id = i * nTiles.width() + j;
QSharedPointer t(new tile(id,
   QPoint(j * tileSize, i * tileSize),
   tileSize, this));
connect(t.get(), ::loadingDone,
this, ::tileLoaded);
connect(t.get(), ::remappingDone,
this, ::tileRemapped);
mTiles.append(t);
}
}

So there you can see that the tileManager class owns the shared pointer to each 
tile, and I also 
connect up a couple signals which are used to convey status back to the 
tileManager which in turn
emits status signals back up to my UI class so it can show progress bars to the 
user that something 
is actually happening since this is a lengthy operation.

>
> Mainly, do as much as possible to reduce the time in the nested loop.

I'm not sure there's anything else I can do to reduce the time in the loop, 
beyond changing the tile 
class to no longer inherit from QObject, and just have it be a pure data class, 
but I'm open to any 
suggestions.

I probably should have mentioned in an earlier email that this is my first 
attempt at using 
QtConcurrent (if that wasn't obvious already), so I'm extremely open to any 
suggestions of refactoring 
that helps out this process. 

Disregarding anything I'm currently attempting, at a high level, this is the 
problem I'm trying to solve:
  1. We have a large file on disk that contains data that we want to convert to 
a grayscale image to 
display to the user. This data is organized similar to an image in the 
sense that it can be thought of 
as a rectangular grid of "pixels", but 

Re: [Interest] [External]Re: How to get QtConcurrent to do what I want?

2022-01-30 Thread Murphy, Sean
Right now, I'm not even actually extracting anything from the original image, 
so far I'm just kind of setting up my proof-of-concept that I'm going down the 
right path.

In my current code, the tile constructor is literally empty (other than the 
automatic assignments to mPos & mSize) and my tile::process() is just a dummy 
function that randomly selects a certain number of milliseconds to sleep to 
simulate that it's doing some work:

void tile::process()

{

// mRNG below is a QRandomNumberGenerator

int delay = mRNG.bounded(5, 21);

QThread::msleep(delay);

}

My current testing is involving around 60,000 tiles (which is quite realistic 
given our actual image dimensions), and on my fairly old & slow laptop, that 
tile creation loop in tileManager::setup() takes around 5 seconds to create all 
60,000 tiles. So that's 5 seconds since the very first tile was created before 
that first tile even begins to process its subset region from the original 
image. I'd like to see what I can do to change that, so that as soon as the 
first tile is created, it starts processing its subset, and each subsequent 
tile begins processing its own subset region as soon as it is created, thereby 
making better use of the 5 seconds it takes to create 60,000 tiles... But since 
as far as I can tell (and let me know if any of these is false):

  1.  QtConcurrent::map(tiles, processTile) needs a fully populated list to 
begin
  2.  Once QtConcurrent::map() begins executing processTile() in parallel on 
each tile, there's no way to tell which tile in the list you're working on 
other than whatever information you already populated in the tile itself before 
you called QtConcurrent::map()
  3.  There's no way to make processTile() contain any automatically 
incrementing arguments that would allow you to detect which iteration you're 
currently on

Assuming I have all those correct, I'm not seeing how I can spread out the tile 
CREATION over multiple threads in a way that correctly assigns the tile's 
subset region.

Since this is just a proof-of-concept, I'm happy to share the whole project 
(once I clean it up a little...). I'm also willing to refactor the design if 
needed. I'm not sure what other options there are. The list that I pass to 
QtConcurrent::map() is always going to be 60,000 items in my example project, 
so even if I'm creating QPoints instead of tiles, I still need to create 60,000 
of them. And the number of tiles in the real world it will vary of course, but 
I'm betting that 60,000 tiles isn't our maximum count.

The other idea I'm considering is creating a tileManagerManager class that 
breaks up the main image into smaller (but still quite large regions), each 
region managed by a single tileManager as we've implemented above. For example 
instead of creating one tileManager object that processes 60,000 tiles as I'm 
doing now, I could create 60 tileManagers that are each processing 1000 tiles. 
They'd still have the same for loop, but now the first tile created would only 
need to wait for 999 more tiles to be created before it starts processing, 
instead of 59,999.

Sean

From: Interest  on behalf of Tony Rietwyk 

Sent: Sunday, January 30, 2022 8:26 PM
To: interest@qt-project.org 
Subject: Re: [Interest] [External]Re: How to get QtConcurrent to do what I want?


That's looks OK.  Why does the tile object creation take so long?  Is all of 
the image handling in tile::process, or does tile constructor extract from the 
original?


Regards, Tony


On 31/01/2022 11:59 am, Murphy, Sean wrote:
Thanks for the response, but I'm not following your suggestion - or at least 
I'm not seeing how it's different than what I'm doing? Maybe a little 
pseudocode will help. Here's what I'm currently doing:

Tile class:
private:
  QPoint mPos;

  int mSize;

tile::tile(QPoint pos, int size) :

mPos(pos),


mSize(size)

{

  // assigns this tile an mSize x mSize square

  // from the original image starting at mPos

  // pixel location in the original image

}

void tile::process()

{

  // does the work on the assigned subset

}


TileManager:
private:
  QVector> mTiles;

processTile(QSharedPointer& t)
{
  t->process();
}

tileManager::setup(QSize tileGrid, int tileSize)
{
  // generate each tile with its assignment

  for(int i=0; i < tileGrid.height(); ++i)

  {

for(int j=0; j < tileGrid.width(); ++j)

{

  // create the new tile while assign its

  // region of the original image

  QSharedPointer t(new tile(


   QPoint(j * tileSize, i * tileSize),

   tileSize));

  mTiles.append(t);

}

  }

  QtConcurrent::map(mTiles, processTile);

}

So I think I'm already doing what you're saying? Where I'm paying the penalty 
is that the allocation of each tile is happening in one thread and I'd like to 
see if I can thread out the object creation. But I don't see how to 
simultaneously threa

Re: [Interest] [External]Re: How to get QtConcurrent to do what I want?

2022-01-30 Thread Murphy, Sean
Thanks for the response, but I'm not following your suggestion - or at least 
I'm not seeing how it's different than what I'm doing? Maybe a little 
pseudocode will help. Here's what I'm currently doing:

Tile class:
private:
  QPoint mPos;

  int mSize;

tile::tile(QPoint pos, int size) :

mPos(pos),

mSize(size)

{

  // assigns this tile an mSize x mSize square

  // from the original image starting at mPos

  // pixel location in the original image

}

void tile::process()

{

  // does the work on the assigned subset

}


TileManager:
private:
  QVector> mTiles;

processTile(QSharedPointer& t)
{
  t->process();
}

tileManager::setup(QSize tileGrid, int tileSize)
{
  // generate each tile with its assignment

  for(int i=0; i < tileGrid.height(); ++i)

  {

for(int j=0; j < tileGrid.width(); ++j)

{

  // create the new tile while assign its

  // region of the original image

  QSharedPointer t(new tile(

   QPoint(j * tileSize, i * tileSize),

   tileSize));

  mTiles.append(t);

}

  }

  QtConcurrent::map(mTiles, processTile);

}

So I think I'm already doing what you're saying? Where I'm paying the penalty 
is that the allocation of each tile is happening in one thread and I'd like to 
see if I can thread out the object creation. But I don't see how to 
simultaneously thread out the tile objection creation AND correctly assign the 
tile its location since as far as I can tell, when QtConcurrent executes 
tileManager's processTile function in parallel there's nothing I can poll 
inside tileManager::processTile() that allows me to know WHICH step I'm at.

Or am I misunderstanding what you're saying?

The best thing I can come up with is that maybe I could change the type of my 
mTiles vector to be a QVector> but then I'd still need to loop through 
nested for-loop to populate all the QPoint items in the vector I want to pass 
to QtConcurrent::map(). I have tried that yet to see if generating thousands of 
QPoint objects is faster than generating the same number of tiles, but I can 
test that out.

Sean

From: Interest  on behalf of Tony Rietwyk 

Sent: Sunday, January 30, 2022 7:19 PM
To: interest@qt-project.org 
Subject: [External]Re: [Interest] How to get QtConcurrent to do what I want?


CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and know the content 
is safe.


Hi Sean,


Can you use the position of the tile as a unique key?  Then the manager only 
needs to calculate each tile's position in the original image.  Each tile 
extracts the bits, processes and notifies the result with its position.


Regards, Tony



On 31/01/2022 10:06 am, Murphy, Sean wrote:
I'm hitting a design issue with the way I'm using the QtConcurrent module to do 
some image processing, and I'm wondering if someone can give some pointers?

At a high level, the software needs to do some processing on every pixel of an 
image. The processing can mostly be done in parallel, so I've created the 
following:

  1.  Tile class - responsible for doing the processing on a small subset of 
the original image
 *   Has a constructor that takes a Position and Size. From those 
parameters, the Tile knows what subset of the original image it is going to 
process
 *   Has a process() function which will do the work on those assigned 
pixels
  2.  TileManager class - responsible for managing the Tile objects
 *   Contains a for-loop that creates each Tile object, assigns it a unique 
Position, and adds it to the QVector vector
 *   Has a processTile(Tile& t) function which calls t.process() to tell a 
given Tile to begin its work
 *   Calls QtConcurrent::map(tiles, processTile) to process each tile

So far this works well, but as I was timing different parts of the codebase, I 
discovered that a large portion of the time is spent allocating the 
QVector vector (step 2a above) before I get to the concurrent processing 
call. The reason why is obvious to me - I need to ensure that each tile is 
created with a unique assignment and as far as I can see, that need to happen 
in a single thread? If I could instead pass off the Tile creation to the 
parallel processing step, I might be able to improve the overall performance, 
but I don't see a way around it within the QtConcurrent framework.

How can I go about creating Tile objects in parallel AND ensure that each of 
them gets a unique Position assignment? I could easily move the Tile allocation 
into processTile(), but if I do that, I don't see a way make the unique 
position assignment since I don't see how a given call to processTile() would 
know where it is in the overall parallelization sequence to determine what 
Position to assign to the Tile it creates. If I were using something like CUDA, 
I could use things like blockIdx and threadIdx to do that, b

[Interest] How to get QtConcurrent to do what I want?

2022-01-30 Thread Murphy, Sean
I'm hitting a design issue with the way I'm using the QtConcurrent module to do 
some image processing, and I'm wondering if someone can give some pointers?

At a high level, the software needs to do some processing on every pixel of an 
image. The processing can mostly be done in parallel, so I've created the 
following:

  1.  Tile class - responsible for doing the processing on a small subset of 
the original image
 *   Has a constructor that takes a Position and Size. From those 
parameters, the Tile knows what subset of the original image it is going to 
process
 *   Has a process() function which will do the work on those assigned 
pixels
  2.  TileManager class - responsible for managing the Tile objects
 *   Contains a for-loop that creates each Tile object, assigns it a unique 
Position, and adds it to the QVector vector
 *   Has a processTile(Tile& t) function which calls t.process() to tell a 
given Tile to begin its work
 *   Calls QtConcurrent::map(tiles, processTile) to process each tile

So far this works well, but as I was timing different parts of the codebase, I 
discovered that a large portion of the time is spent allocating the 
QVector vector (step 2a above) before I get to the concurrent processing 
call. The reason why is obvious to me - I need to ensure that each tile is 
created with a unique assignment and as far as I can see, that need to happen 
in a single thread? If I could instead pass off the Tile creation to the 
parallel processing step, I might be able to improve the overall performance, 
but I don't see a way around it within the QtConcurrent framework.

How can I go about creating Tile objects in parallel AND ensure that each of 
them gets a unique Position assignment? I could easily move the Tile allocation 
into processTile(), but if I do that, I don't see a way make the unique 
position assignment since I don't see how a given call to processTile() would 
know where it is in the overall parallelization sequence to determine what 
Position to assign to the Tile it creates. If I were using something like CUDA, 
I could use things like blockIdx and threadIdx to do that, but as far as I can 
see, those concepts don't exist (or at least aren't exposed) in QtConcurrent.

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


Re: [Interest] [External]Re: Proxied view not updating live when source model does

2021-09-22 Thread Murphy, Sean
Thanks for the response, but no, that’s not it. Modifying my baseModel’s 
setData from
emit dataChanged(index, index, QVector() << role);
to
emit dataChanged(index, index, QVector() << role << Qt::DisplayRole);
changes nothing in the behavior…

From: Interest  On Behalf Of Björn Schäpers
Sent: Wednesday, September 22, 2021 2:46 PM
To: interest@qt-project.org
Subject: [External]Re: [Interest] Proxied view not updating live when source 
model does

CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and know the content 
is safe.

You emit dataChanged with the given role (which is Qt::EditRole), but not for 
Qt::DisplayRole. Is it that?

Regards,
Björn.

Am 20.09.2021 um 19:15 schrieb Murphy, Sean:

I'm having an issue where my proxy model and its associated view aren't 
updating live when changes

are made in the source model.



My proxy model simply is attempting to invert the rows of the source model. So 
it inherits from a

QSortFilterProxyModel and implements mapFromSource() and mapToSource() as 
follows:



QModelIndex invertRowsModel::mapFromSource(const QModelIndex ) 
const

{

if(sourceIndex.isValid() && rowCount() > 0)

{

return this->index(rowCount() - sourceIndex.row() - 1, 
sourceIndex.column());

}



return QModelIndex();

}



QModelIndex invertRowsModel::mapToSource(const QModelIndex ) 
const

{

if(proxyIndex.isValid() && sourceModel() && rowCount() > 0)

{

return sourceModel()->index(rowCount() - proxyIndex.row() - 1, 
proxyIndex.column());

}



return QModelIndex();

}



I load up my source model with some data, connect the models up to their 
respective views,

connect the source model to the proxy and launch the application. The original 
views are

correct - the proxied rows are flipped when compared to the source model. But 
then if the

user makes a change to some of the data in the source model's view, the 
corresponding index

in proxy model's view is NOT updated automatically. HOWEVER, if the user then 
clicks within

the proxy view, or clicks outside of my application, the proxy model will then 
repaint and the

updated information is correctly shown.



I've attached a minimal example that shows the behavior. Things to note:

1. When the source model emits its dataChanged(), this seems to trigger a 
dataChanged()

  emission in the proxy model as well. The weird (at least to me) thing is that 
both of those

  signals have the SAME model index row & column numbers. I would have expected 
that

  when the source model emits data changed, that the proxy model would 
translate the

  source model's indices into the proper proxy model's indices via the 
mapFromSource()

  function and then emit dataChanged() with those indices. I've got debug 
statements in

  my example to illustrate that no dataChanged() translation is happening - if 
the user

  updates data in row 0 in the source model's view, the proxy model also emits 
that data

  changed in its row 0, but that isn't the correct row for the proxy.

2. We discovered that if we connect the proxy model's dataChanged() signal to a 
custom

  slot within the proxy model, and have that slot emit layoutChanged() then we 
can get

  the live update behavior when the source model updates. This is at line 25 of

  invertrowsmodel.cpp. It's commented out initially, but if you uncomment it 
and re-run

  the app then proxy view does update instantly. Other similar signals would 
work as well -

  we just need something triggers the proxy view to refresh the data in the 
proxied view,

  but we don't think we should really have to do this...

3. I have a second view attached to the source model and both source model 
views update

  each other live - changes in one source model view are instantly updated in 
the other

  source model view, but not in the proxy model view without further user 
interaction

  (or by emitting that layoutChanged() signal)



Any thoughts as to why the proxy model isn't updating correctly?

Sean



___

Interest mailing list

Interest@qt-project.org<mailto: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] Proxied view not updating live when source model does

2021-09-22 Thread Murphy, Sean
> to both rowCount() and columnCount() removed those errors and now my
> application runs silently.

I should have explained better. It runs silently in the sense that 
the QAbstractItemModelTester instances aren't printing out 
any information any more.

The broken behavior still exists where the view connected to the 
proxy model isn't repainting the corresponding row as the source 
model's data changes. Instead it is repainting the same row as 
the source.

For example:  
1. If initially populate the source model with 3 rows of data
  A  1
  B  2
  C  3
  The proxied view correctly shows this data inverted:
  C 3
  B 2
  A 1
2. If I then edit cell (0,0) in the source view from 'A' to 'Z':
  Z  1
  B  2
  C  3
  The proxied view doesn't update, still showing an 'A' in cell 
  (2,0) which is supposed to map to source (0,0):
  C 3
  B 2
  A 1
3. If I then edit cell (2,0) in the source view from 'C' to 'X':
  Z  1
  B  2
  X  3
  The proxy view updates to:
  C 3
  B 2
  Z 1

I still think the problem is that the dataChanged() signal that 
automatically gets emitted by the proxy model off from the 
source model's dataChanged() signal has the EXACT SAME 
INDEX as the source model:

"baseModel::slotDataChanged: Index: (2, 0)"
"invertRowsModel::slotDataChanged: Index: (2, 0)"

I think the correct behavior for the proxy should be that when 
the source's dataChanged() signal fires, the indices in that 
signal should be translated through mapFromSource() to then 
get re-emitted from the proxy model so the attached view would 
then call the proxy's data() with the mapped index (in this example, 
when source data changes at (2,0) the proxied view should be 
informed that index (0,0) changed to refresh that data), but that 
doesn't seem to be happening automatically...

Sean

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


Re: [Interest] Proxied view not updating live when source model does

2021-09-22 Thread Murphy, Sean
> > have you run  QAbstractItemModelTester
> > https://doc.qt.io/qt-6/qabstractitemmodeltester.html on the source
> > model and the proxy model?

Ok, I think I'm now using the tester, but I'm not sure I'm using it correctly. 
After I've populated my base model, assigned it as the source model to my 
proxy, and then connected the models up to their respective views I call:

QAbstractItemModelTester* baseModelTester = new 
QAbstractItemModelTester(mBaseModel,
 
QAbstractItemModelTester::FailureReportingMode::Warning,
 
this);
QAbstractItemModelTester* proxyModelTester = new 
QAbstractItemModelTester(mInvertRowsProxy,
  
QAbstractItemModelTester::FailureReportingMode::Warning,
  
this);

And then run the rest of my application normally. On first launch after adding 
those lines I saw the following statement twice in QtCreator's Application 
Output pane:

  qt.modeltest: FAIL! model->hasChildren(topIndex) () returned FALSE 
(qabstractitemmodeltester.cpp:366)

A quick google on that pointed to the fact that I was always returning my data 
size for rowCount() and 2 for columnCount() regardless of whether the parent 
index was valid or not. So adding:

if(parent.isValid())
{
return 0;
}

to both rowCount() and columnCount() removed those errors and now my 
application runs silently.

Am I using the model index tester correctly?
Any other ideas on how to get this working?

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


Re: [Interest] [External]Re: [External] Proxied view not updating live when source model does

2021-09-22 Thread Murphy, Sean
> have you run  QAbstractItemModelTester
> https://doc.qt.io/qt-6/qabstractitemmodeltester.html on the source model and
> the proxy model?

I had not, mostly because I didn't know it existed! Time to learn a new class 
today. 
I'll report back if I find something that fixes my issue.

Thanks,
Sean

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


Re: [Interest] [External] Proxied view not updating live when source model does

2021-09-21 Thread Murphy, Sean
> I'm having an issue where my proxy model and its associated view aren't
> updating live when changes are made in the source model.
> 
> My proxy model simply is attempting to invert the rows of the source model. So
> it inherits from a QSortFilterProxyModel and implements mapFromSource() and
> mapToSource() as follows:
> 
> QModelIndex invertRowsModel::mapFromSource(const QModelIndex
> ) const
> {
> if(sourceIndex.isValid() && rowCount() > 0)
> {
> return this->index(rowCount() - sourceIndex.row() - 1,
> sourceIndex.column());
> }
> 
> return QModelIndex();
> }
> 

Small update here, but I'm not sure what it actually means... I added a debug 
statement at the top of my mapFromSource() function, so now that function reads 
like so:  

QModelIndex invertRowsModel::mapFromSource(const QModelIndex ) 
const
{
if(sourceIndex.isValid() && rowCount() > 0)
{
qDebug() << __FUNCTION__ << "valid index" << sourceIndex;
return this->index(rowCount() - sourceIndex.row() - 1, 
sourceIndex.column());
} else {
qDebug() << __FUNCTION__ << "invalid index" << sourceIndex;
}

return QModelIndex();
}

With this in place, while modifying the data in the source view, I NEVER see 
the 
mapFromSource() "valid index" debug message from the proxy model. Right after 
setData() is called in the source model, I see a couple of these messages come 
out 
and that's it:

  invertRowsModel::mapFromSource invalid index 
QModelIndex(-1,-1,0x0,QObject(0x0))  

I'm not sure exactly what that means or how to address it, but it is a new data 
point...

Sean

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


[Interest] Proxied view not updating live when source model does

2021-09-20 Thread Murphy, Sean
I'm having an issue where my proxy model and its associated view aren't 
updating live when changes 
are made in the source model.

My proxy model simply is attempting to invert the rows of the source model. So 
it inherits from a 
QSortFilterProxyModel and implements mapFromSource() and mapToSource() as 
follows:

QModelIndex invertRowsModel::mapFromSource(const QModelIndex ) 
const
{
if(sourceIndex.isValid() && rowCount() > 0)
{
return this->index(rowCount() - sourceIndex.row() - 1, 
sourceIndex.column());
}

return QModelIndex();
}

QModelIndex invertRowsModel::mapToSource(const QModelIndex ) 
const
{
if(proxyIndex.isValid() && sourceModel() && rowCount() > 0)
{
return sourceModel()->index(rowCount() - proxyIndex.row() - 1, 
proxyIndex.column());
}

return QModelIndex();
}

I load up my source model with some data, connect the models up to their 
respective views, 
connect the source model to the proxy and launch the application. The original 
views are 
correct - the proxied rows are flipped when compared to the source model. But 
then if the 
user makes a change to some of the data in the source model's view, the 
corresponding index 
in proxy model's view is NOT updated automatically. HOWEVER, if the user then 
clicks within 
the proxy view, or clicks outside of my application, the proxy model will then 
repaint and the 
updated information is correctly shown. 

I've attached a minimal example that shows the behavior. Things to note:  
1. When the source model emits its dataChanged(), this seems to trigger a 
dataChanged() 
  emission in the proxy model as well. The weird (at least to me) thing is that 
both of those 
  signals have the SAME model index row & column numbers. I would have expected 
that 
  when the source model emits data changed, that the proxy model would 
translate the 
  source model's indices into the proper proxy model's indices via the 
mapFromSource() 
  function and then emit dataChanged() with those indices. I've got debug 
statements in 
  my example to illustrate that no dataChanged() translation is happening - if 
the user 
  updates data in row 0 in the source model's view, the proxy model also emits 
that data 
  changed in its row 0, but that isn't the correct row for the proxy.
2. We discovered that if we connect the proxy model's dataChanged() signal to a 
custom 
  slot within the proxy model, and have that slot emit layoutChanged() then we 
can get 
  the live update behavior when the source model updates. This is at line 25 of 
  invertrowsmodel.cpp. It's commented out initially, but if you uncomment it 
and re-run 
  the app then proxy view does update instantly. Other similar signals would 
work as well - 
  we just need something triggers the proxy view to refresh the data in the 
proxied view, 
  but we don't think we should really have to do this...
3. I have a second view attached to the source model and both source model 
views update 
  each other live - changes in one source model view are instantly updated in 
the other 
  source model view, but not in the proxy model view without further user 
interaction 
  (or by emitting that layoutChanged() signal)

Any thoughts as to why the proxy model isn't updating correctly?
Sean
<>
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Replacing QListWidget that uses cell widgets with QListView & model

2021-09-03 Thread Murphy, Sean
We've got an application we're working on where we'd like to replace a 
QListWidget that uses 
cell widgets, with a view/model/delegate and we're running into a snag. Here's 
what we have:

We have a "layerData" class with three member variables:
- bool visible
- QString name
- double opacity

We have a custom "layerControl" widget class that has three controls 
(QToolButton, QLineEdit, QSlider 
respectively) for displaying/setting those parameters. This widget has separate 
signals (bool, QString, 
double) which are emitted when their respective control is modified. 

Originally, we had a QListWidget where we'd call setCellWidget(new 
layerControl()) to populate 
the list with one our "layerControl" widgets per row. This worked well, but now 
we've realized that 
we want to display this same information in a couple different views (some of 
which are QTableViews, 
some are QListViews), so we're converting everything over to 
view/model/delegate so that we can 
just use a single shared model and changes that are made on any view are 
immediately reflected in the 
other views.

To convert over to the view/model/delegate way of doing things I've got this so 
far: 
- I've created a model (inherited from QAbstractItemModel) that takes a 
QVector for 
  its underlying data, and in data() returns the bool parameter for column 0, 
the QString parameter 
  for column 1, and the double for column 2. 
- I set the same instance of this model on both a QTableView and a QListView
- I've created a delegate class, "layerWidgetDelegate",  that uses our 
"layerControl" widget as its editor
- on the QListView, I call setItemDelegateForColumn(0, new 
layerWidgetDelegate()), and then I loop 
  though all the rows of the view, calling 
openPersistentEditor(model->index(row, 0)) so the 
  "layerControl" widgets are always shown in the QListView
- in the delegate, I've connected the editor's 3 distinct signals (bool, 
QString, double) up to calling the 
  model's setData() function with the appropriate column (0, 1, 2 respectively)

This setup works fine when the user makes a change in the QListView. Using the 
"layerControl"  item 
delegate/editor to make a change on any of the three parameters, the change 
immediately ripples 
through the model and the table view is updated to match. But we're having 
trouble going the other 
way, but only for columns 1 & 2. If the user makes a change in the table view 
to something in column 0, 
that change propagates through the model, the delegate's setEditorData() is 
called with an index 
of (row, 0), and then the editor widget's QToolButton's state is updated to 
match the new value. But if 
the user makes a change in the table view to something in column 1, the model's 
underlying data is correctly
updated, it still emits the correct dataChanged() signal for the index (row, 
1), but the item delegate's 
setEditorData() function is never called and therefor the QLineEdit is never 
updated. The same thing 
happens if the user makes a change in the table view to something in column 2 - 
the model's setData() is 
correctly called, the dataChanged() signal is correctly emitted, but the 
delegate's setEditorData() function 
is never called, and therefore the QSlider never gets updated.

Anyone have any tips for this? The basic problem with what I'm doing is that 
I'm trying to use a three 
column model in a single column widget (the QListView), but I STILL want all 
three columns of data to 
come through because I need to populate the delegate. It appears something in 
the QListView 
class prevents setEditorData() from being called when the index isn't in column 
0.

The only hack I've found that works so far is in my model's setData() function, 
if the passed in index is for 
column 1 or 2, then I make sure to emit column 0 in the dataChanged() signal, 
which then forces the 
view to call the setEditorData() function, and then in there I update the 
editor widget with all three 
types of data since I don't really know which column changed at that point.

This was more long winded than I wanted, hopefully you can follow all of this!
Sean




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


[Interest] List traffic disappearing?

2021-08-19 Thread Murphy, Sean
I've been on this list (and it's predecessor) for a couple of decades, and have 
noticed that the traffic on it seems to have slowed significantly over the past 
few months. Is there somewhere else people are going, like 
https://forum.qt.io/, or have people just stopped discussing Qt for some other 
reason?

Sean 

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


Re: [Interest] [External] Text: remove empty space at top or get its size

2021-04-13 Thread Murphy, Sean
> I want to center vertically image and text. But when I'm trying to, it does 
> not
> look centered, because of an empty space at the top of the text.
> What I mean is illustrated by this image:
> 
> The blue rectangle looks a bit above the text. However, these two controls are
> centered actually. The second image illustrates this by showing text's 
> bounding rectangle.
> 
> Is there any way to remove this few empty lines of pixels at the top in the 
> text control?
> Or at least somehow get its height so I can take this into account manually?

Have you looked at font metrics 
(https://doc.qt.io/qt-5.12/qml-qtquick-fontmetrics.html)? I've never played 
around with the parts your concerned about specifically, but it looks like 
maybe your answer may lie somewhere in the ascent and/or tightBoundingRect() 
areas?

Sean




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


Re: [Interest] [External]Re: download.qt.io is down

2021-01-19 Thread Murphy, Sean
I don't seem to be having much luck with the online installer for the open 
source Mac binaries. I downloaded the Mac online installer today 
(qt-unified-macOS-x86_64-4.0.1-online), I had no trouble doing that.

Then when running it, I put in my account info, and am able to log in. I get 
past the Qt Open Source Usage Obligations page, then on the Setup - Qt page, I 
get the "Preparing meta information downlod..." progress bar which stays in 
indeterminate progress mode for a while and then eventually everything times 
out with "Cannot retrieve remote tree."

If it matters, this is a new install on a machine that has not had Qt 
previously installed on it.
Sean

From: Interest  On Behalf Of Tuukka Turunen
Sent: Tuesday, January 19, 2021 3:09 PM
To: Mark Long 
Cc: developm...@qt-project.org; Interests Qt ; 
releas...@qt-project.org
Subject: [External]Re: [Interest] download.qt.io is down

CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and know the content 
is safe.


Hi,

There are multiple mirrors, try for example:



https://qt-mirror.dannhauer.de/

https://www.funet.fi/pub/mirrors/download.qt-project.org/

https://ftp.fau.de/qtproject/


...or just use the online installer, which picks mirrors automatically.

Yours,

Tuukka


Lähettäjä: Mark Long mailto:markdlong...@gmail.com>>
Lähetetty: tiistaina, tammikuuta 19, 2021 9:58 ip.
Vastaanottaja: Tuukka Turunen
Kopio: Jani Heikkinen; 
developm...@qt-project.org; 
releas...@qt-project.org; Interests Qt
Aihe: Re: [Interest] download.qt.io is down

It seems that the only mirror list I can find online is served from 
download.qt.io, which is quite unhelpful at the moment.  
Does anyone have a mirror link handy or a link to another list somewhere else?

Thanks much!
Mark

On Tue, Jan 19, 2021 at 12:59 PM Tuukka Turunen 
mailto:tuukka.turu...@qt.io>> wrote:
Hi,

Update on the status. The downtime is caused by severe disk system failure at 
our cloud service provider. The service provider has notified us that they will 
not be able to repair the disk systems during today.

Two important servers related to open-source package delivery are affected 
(download frontend and delivery system master). Mirrors are not affected, so 
online installer works and also offline packages can be downloaded directly 
from the mirrors. Commercial package distribution is done via a different 
system, which is not affected by this.

Yours,

Tuukka

From: Development 
mailto:development-boun...@qt-project.org>>
Date: Tuesday, 19. January 2021 at 11.21
To: developm...@qt-project.org 
mailto:developm...@qt-project.org>>, 
releas...@qt-project.org 
mailto:releas...@qt-project.org>>
Subject: [Development] download.qt.io is down
Hi all,

You have most probably already noticed that 
download.qt.io is down. We are fixing the issue so 
please be patient. I'll inform you when it should work OK

br,
Jani Heikkinen
Release Manager
___
Development mailing list
developm...@qt-project.org
https://lists.qt-project.org/listinfo/development
___
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] ** Caution Message may be spoofed ** Re: Sharing QItemSelectionModel with multiple views/proxy models

2020-09-28 Thread Murphy, Sean
> > I'm trying to get selections on one view to be replicated to the
> > other[...]> So how do I connect things up so that selections on view1
> > are propagate through the proxy model, and then the respective indices
> > are selected in view2, and vice versa?
> 
> Use QAbstractProxyModel::mapToSource() and mapFromSource(), or
> mapSelectionToSource() and mapSelectionFromSource().
> 
> Eg:
> QObject::connect(
> sourceSelectionModel,
> ::selectionChanged,
> proxySelectionModel,
> [&](const QItemSelection ) {
> QItemSelection newSet = proxyModel->mapSelectionFromSource(set);
> proxySelectionModel->select(newSet,
> QItemSelectionModel::ClearAndSelect);
> });
> 
> Repeat for each of the signals for QItemSelectionModel changes that should be
> mirrored, for each selection model. You can save some overhead by tracking
> which view originated the change, but QItemSelectionModel will detect empty
> change sets.

Thanks for the response. I ended up doing roughly the same thing.

I should have been more clear in my original post. I had found what looked like 
the relevant signals/functions to do the mapping as you described above before 
I 
posted. I wanted to make sure that I wasn't missing something in the 
model/selection model/proxy model system that AUTOMATICALLY made these 
connections for you. It seemed to me like this would be a fairly common use 
case - 
having multiple views that have differing levels of proxies, all feeding off 
from a 
common underlying data model, and wanting selections to be shared among views, 
once they are filtered through the proxies.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Sharing QItemSelectionModel with multiple views/proxy models

2020-09-24 Thread Murphy, Sean
What's the best way to share selections between views when you're dealing with 
different levels of models and proxy models between the separate views?

I've got the following setup:
-  myData: a data only class that holds the underlying values to be displayed
- dataModel: a model that operates directly on myData 
- proxyModel:  a proxy model that dataModel as source model
 - view1: a QTableView that uses dataModel for its model
 - view2: another QTableView that uses proxyModel for its model

I'm trying to get selections on one view to be replicated to the other, so I 
originally assumed I'd just share a single selection model between them, so I 
do roughly the following:
  QAbstractTableModel* dataModel = new QAbstractTableModel(this);
  QAbstractProxyModel* proxyModel = new QAbstractProxyModel(this);  
  QItemSelectionModel* sharedSelectionModel = new 
QItemSelectionModel(dataModel);

  view1-> setModel(dataModel);

  proxyModel->setSourceModel(dataModel);
  view2->setModel(proxyModel);
 
  view1->setSelectionModel(sharedSelectionModel);
  view2->setSelectionModel(sharedSelectionModel);

That last call, attempting to set the selection model of view2 to 
sharedSelectionModel, fails since view2's model is the proxyModel, but the 
sharedSelectionModel that I'm attempting to set as the selection model operates 
on the dataModel. I get the reason why, but not what the best approach is to 
get around it.

So how do I connect things up so that selections on view1 are propagate through 
the proxy model, and then the respective indices are selected in view2, and 
vice versa?

Sean 





This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QActions not moved to application menu properly

2020-09-22 Thread Murphy, Sean
I'm not on a Mac right now, so I can't try this, so I don’t know if this will 
work:

As each window (I assume these are QMainWindow, or at least inherit from 
one) is closed, are you deleting them? If so, when you get to the last one, 
could 
you hide it instead of deleting it? Or when you've deleted the last one, then 
immediately create a new one and hide it?

My theory being that maybe for Qt to do it's Mac menu magic, there needs 
to always be a QMainWindow present (but not necessarily shown)?

Just a total guess on my part...
Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Pause QTableView while model continues to update

2020-07-08 Thread Murphy, Sean
Is there a way to temporarily pause a QTableView while the underlying model 
continues to update?

My scenario: 
 - I have two separate QTableViews connected to a single model. 
 - The model is being fed from a continuously updating data source, i.e. a 
sensor. 
 - One of the views needs to remain live at all times - so as the model's data 
updates, the view updates immediately. 

For the other view, the user should be able to "pause" that view's display, 
spend as much time as they want looking at the data on that paused table, and 
then whenever they choose, they can un-pause that view and it returns to 
updating constantly. This view has to remain fully usable (scroll bars work, 
clicks work, etc.) while paused.

The only idea I have at the moment is to have a second model object, that is 
identical to the first one, except that it isn't connected to the sensor. At 
the time the user wants to pause the view, I copy the current data out of the 
main model into the second model, swap out the paused view's model out to the 
second model, and then swap it back to the main model when the user wants to go 
back live.

Am I missing something easier? The only other idea I had was that I could try 
to change the second view from a pure QTableView to one that inherits from 
QTableView and then have my own slot that disconnects/connects the signals 
between the model and that view based on the when the user wants to 
pause/resume.

Sean 




This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Disable automatic shortcuts for certain widgets?

2020-06-09 Thread Murphy, Sean
> Why not just replace ‘&’ with ‘&&’ in the string the user inputs, before
> setting it as the name on the tab?

That might work, the only wrinkle I see is that when the user goes to edit a 
tab name, we start out the editor with the "current" text so I'd have to 
substitute back the other way when editing, replacing the "&&" that is actually 
in the current string with the '&' that the user is expecting to see, but that 
wouldn't be too hard to do I guess.

Thanks,
Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Disable automatic shortcuts for certain widgets?

2020-06-09 Thread Murphy, Sean
In our application, we have a QTabWidget. We allow the users to rename the 
tabs. One of our users discovered that if they put an '&' in the string, it 
isn't displayed, and if they put two together in sequence ("&&"), a single '&' 
is displayed on the tab widget.

I completely understand what's happening, the text they are entering is being 
evaluated by the native widgets for the presence of the '&' character to 
automatically create shortcuts as described here: 
https://doc.qt.io/qt-5/qabstractbutton.html#text-prop.

In other parts of our application, I do want the automatic shortcut 
functionality (i.e. having the  for the File menu is something I'd like to 
keep), but for this specific tab widget I'd like to disable that functionality 
since our users aren't software developers and they find it weird that the 
ampersand character behaves differently than other characters in the string.

I don't see any way to disable that functionality though, is there one that I'm 
missing?

Sean




This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QSpinbox repeat delay

2019-12-04 Thread Murphy, Sean
> As with any similar widget platform-specific behavior, specifically by the
> SH_SpinBox_ClickAutoRepeatThreshold style hint. Use
> spinbox->style()->styleHint to fetch the value; use a custom style or a
> proxy style to change it.

Thanks for teaching me something new! I had no idea things like that 
were part of widgets' styles. In my head "style" only applied to visual 
things - basically  I was thinking QStyle == QStylesheet, or at least 
something very similar.

Time to read up on a "new-to-me" class...
Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] QSpinbox repeat delay

2019-12-03 Thread Murphy, Sean
When using a QSpinBox, if the user clicks and holds on one of the up/down 
buttons (or uses one of the keyboard keys that do the same thing), there is a 
bit of a delay before the autorepeat functionality starts.

Is there a spot to query what that delay is and/or change it? From trial and 
error it appears it is ~500 ms on Windows, but there doesn't seem to be a way 
to control it.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Question about custom delegates

2019-10-30 Thread Murphy, Sean
I've got a QTableView that I'm putting a custom widget/editor in one column 
to allow editing of data, that I've got a couple of questions about. First, the 
custom widget is simply 3 QRadioButtons in a horizontal layout:

threeRadioButtonWidget
-- QHBoxLayout
 QRadioButton
 QRadioButton
 QRadioButton

And I create the widget in my delegate's createEditor()
QWidget *myDelegate::createEditor(QWidget *parent,
  const QStyleOptionViewItem ,
  const QModelIndex ) const
{
Q_UNUSED(option)
Q_UNUSED(index)
threeRadioButtonWidget* w = new threeRadioButtonWidget(parent);
connect(w, & threeRadioButtonWidget::clicked, 
this, ::editorClicked);
return w;
}

Then, because I want those editors to always be visible I have the following 
in my parent class:
mDelegate = new myDelegate(this);
ui->tableView->setItemDelegateForColumn(3, mDelegate);
for(int i=0; i < mModel->rowCount(); ++i)
{
QModelIndex idx = mModel->index(i, 3, QModelIndex());
ui->tableView->openPersistentEditor(idx);
}

Questions:
1. Is there any way to avoid the openPersistentEditor loop above? The way 
I have it now works, but seems clumsy, especially as changes in the underlying 
data causes row/column counts to change. It seems like I would want to do 
something in my delegate's paint() function to paint the image of the 3 radio 
buttons, but I not seeing how I do that in a way where the real editing widget 
would line up perfectly with the painted image when the user goes to edit.
a. Also, if I set it up where it's no longer a persistent editor, I want it 
so the user 
only has to click once over a radio button to count as a click on the 
radio 
button itself. I don't want the user to have to click in the cell first 
to get the 
editor to activate, then have to click a second time.

2. My selection behavior for the table is QAbstractItemView::SelectRows. When 
the user clicks on a given row to select it, the other cells in the selected 
row get 
the highlighted color, but the background of the cells controlled by this 
delegate 
doesn't change to match. I get why that occurs given the way I have it - since 
I'm 
using openPersistentEditor(), the real three radio button widget is always 
shown, 
and I need to propagate the selection color down to that widget's background 
color for it to work, but I'm assuming that if I get the paint() issue from 
question 
#1 working I could correct it there?

3. I allow the user to drag and drop table rows to reorder the data. As I 
currently 
have the code, the threeRadioButtonWidget object isn't not included in the drag 
pixmap, so while the user is dragging a row, the drag looks "wrong" - it looks 
like 
that column's data isn't coming along with the drag. Again, I'm assuming if I 
fix 
the paint() question above, that might take care of itself?

Sean





This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] ** Caution Message may be spoofed ** Re: Write QSettings to a QString in INI format

2019-10-26 Thread Murphy, Sean
> I suggest QTemporaryDir instead.

Thanks Thiago,
So just create the QTemporaryDir, then feed that path (along with an appended 
filename) to QSettings, allow it to create the INI file within the temporary 
directory, and then let QTemporaryDir clean up that directory when it goes out 
of scope? 

I'm fine with that approach, unless there is any way to avoid the file system 
altogether that I'm not seeing?

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Write QSettings to a QString in INI format

2019-10-26 Thread Murphy, Sean
> > Because QSettings has the file locked. Make sure settings goes out of
> > scope before you re-open the file.
> >
> Granted, it's complex with the locking code, but underneath it all you have
> this hidden gem writeIniFile(), which takes a QIODevice and the map (you
> know, the function with those hardwired [General] and [General%] strings).
> 
> Suggestion: you have this nice extension/plugin call
> QSettings::registerFormat(), which takes a readFunc and a writeFunc ptr.
> If that writeIniFile() could be exposed as a public writeFunc ptr (yes it has 
> the
> same function signature) then you could have users bypass the locking stuff,
> by requiring them to register a new format (say with the extension "buffer"
> for a QBuffer) but allowing them to reuse the existing writeIniFile() as their
> own writeFunc (and say a QBuffer as the QIODevice).
> That way you could access the streaming functionality of QSettings without
> involving the file system.

Is the suggestion to me, or to the Qt development team? Because even if I 
somehow expose the writeIniFile() function so that I can use it, the only 
applicable QSettings constructor that allows me to specify a registered format
is this one:
QSettings(const QString , QSettings::Format format, QObject 
*parent = nullptr)
And the behavior of that constructor is that it opens an actual file on the 
filesystem with "fileName" (use an existing file if the file already existed 
before 
this call, otherwise creating a file with that name if it didn't already 
exist), then 
sets the QIODevice to point at the file, and then uses your registered format's 
function pointers to handle the reading and writing of it. There does not 
appear 
to be any way for me to point the created QSettings object at my QBuffer, even 
if I got access to the writeIniFile(), correct? Or am I missing something?

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Write QSettings to a QString in INI format

2019-10-25 Thread Murphy, Sean
> > So I guess I can use QFile to create my own file, do what I need to
> > do, then remove it myself when I'm done, but is there any alternative
> > way to get what I want - QSetting written to a QString?
> 
> There are overloads of QFile::open() that take a system file handle / file
> descriptor. This one can point to memory. Anyhow, I guess you'll end up
> with platform specific code there ...

But how would I get QSettings to write to there? QSettings doesn't have 
an open(). All it has is one of its constructors takes a QString as a filename, 
and then it opens that file under the hood. So all you can pass to QSettings
is a file NAME. Not a pointer, not a file handle/descriptor.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Write QSettings to a QString in INI format

2019-10-24 Thread Murphy, Sean
I'd like to be able to have QSettings write out my settings to an INI file 
format, but I'd like to avoid writing it to an actual file, instead just 
writing it to "something" in memory (for example, a QString, QByteArray, 
QBuffer, etc.). 

As far as I can tell, there doesn't seem to be any way to do that:
- QSettings doesn't have a constructor that takes any sort pointer to a memory 
type object. It only has constructors for dealing with the platform specific 
settings locations (registry on Windows, plists on Mac, etc), or it has the one 
constructor that takes a filename and will write to a file.
- It appears (unless I'm reading it wrong) that the QSettings::registerFormat 
allows you to customize how settings are written out, but it can only be used 
in conjuction with the filename constructor and will always open a file and 
write to it, but it allows you to customize the format of how the key/value 
pairs are written out - there is an example that writes it out in XML. This 
seems like the opposite of what I want to do, I want QSettings to write out the 
exact same format as it already does with the QSettings::IniFormat, I just want 
to keep it all in memory and avoid creating a file.

So I if all the above is correct, and there is no way to write an INI formatted 
string to memory, and given the fact that I really don't want a file in the 
first place, I decided to look at writing the settings out to a QTemporaryFile, 
then just reading that data back in as a string, and then let the 
QTemporaryFile go out of scope and clean itself up. But according to the 
following test code, QSettings does not seem to play nicely with QTemporaryFile:

void MainWindow::writeSettings()
{
// comment/uncomment the *define* below to switch implementations
#define USE_QTEMPORARY_FILE

#ifdef USE_QTEMPORARY_FILE
// using a QTemporaryFile doesn't seem to work
QTemporaryFile tempFile;
bool ok = tempFile.open();
#else
// if instead you use a regular QFile, it works
QFile tempFile("tempFile.ini");
bool ok = tempFile.open(QIODevice::ReadWrite);
#endif

if(ok)
{
qDebug() << "Opened" << tempFile.fileName();
} else {
qDebug() << "Unable to open" << tempFile.fileName();
}
tempFile.close();

QSettings settings(tempFile.fileName(), QSettings::IniFormat);
settings.setValue("string", "hello");
settings.setValue("int", 2);

settings.sync();
// using QTemporaryFile always produces an AccessError here, 
// QFile reports NoError
qDebug() << settings.status();

QFile file(tempFile.fileName());
ok = file.open(QIODevice::ReadOnly);
QString settingsString = file.readAll();
// at this point, settingsString should contain
//  [General]
//  string=hello
//  int=2
// it does if I use QFile, but is empty when using a QTemporaryFile
qDebug() << settingsString;
}

So I guess I can use QFile to create my own file, do what I need to do, then 
remove it myself when I'm done, but is there any alternative way to get what I 
want - QSetting written to a QString?

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Incorrect widget sizes on Windows?

2019-10-02 Thread Murphy, Sean
I'm encountering an odd widget sizing difference on Windows, namely if I have a 
QPushButton and a QComboBox together in a horizontal layout, and I set them 
both to have the same fixed height, the do not appear to have the same height - 
the combobox appears correct, but the push button is a couple pixels shorter:
[cid:image003.jpg@01D5792C.44563540]

The exact same code running on Linux produces what I'd expect - both widgets 
have the same height:
[cid:image004.jpg@01D5792C.44563540]

Sample code:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);

QPushButton* pb = new QPushButton("Push Me");
pb->setFixedHeight(35);

QComboBox* cmb = new QComboBox();
cmb->addItem("A");
cmb->addItem("B");
cmb->addItem("C");
cmb->setFixedHeight(35);

QTableWidget* table = new QTableWidget(3,2);

QHBoxLayout* hbox = new QHBoxLayout();
hbox->addWidget(pb);
hbox->addWidget(cmb);
hbox->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, 
QSizePolicy::Preferred));

QVBoxLayout* vbox = new QVBoxLayout();
vbox->addItem(hbox);
vbox->addWidget(table);

QWidget* w = new QWidget(this);
w->setLayout(vbox);

setCentralWidget(w);
}

Windows machine is running Windows 10 Pro.
Linux machine is Elementary OS 5.0
Both programs are Qt 5.12.3, 64 bit.



This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Click and hold on close button

2019-08-28 Thread Murphy, Sean
> When it loses focus it stops rendering a cursor altogether (you can test this
> out with another application arranged side-by-side with notepad).

Good point, so at least in the Notepad case, it does appear to follow the same 
behavior as my quick Qt sample application - clicking and holding on one of the 
window minimize/maximize/close buttons causes Notepad's cursor to still be 
visible, but stop blinking, while clicking & holding on Notepad's title bar 
(but not on any actual button) allows the cursor to keep blinking.

Which I think gives me the ammunition I need to say this isn't my application 
doing something weird and we shouldn't waste any time (well, at least more than 
I already have) trying to fix this.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Click and hold on close button

2019-08-28 Thread Murphy, Sean
> If you want to put the effort for this, port to client side decoration and
> handle events in your application.

I mostly don't want to have to deal with it at all, mainly because it takes a 
decent amount of work to execute that correctly, for no real gain, since I 
don't think normal users are likely to do this sequence anyway. The complaint 
was from our QA team that naturally tries to doing weird, crazy things to break 
the application. 

And I actually just did some client side decoration recently for this 
application, and there's issues with that, namely that there are issues with 
custom windows on Windows related to the window shadow and a small 6 pixel 
band. See my earlier post from 8/19/2019: 
https://lists.qt-project.org/pipermail/interest/2019-August/033636.html, so in 
that instance I was forced to choose between having a window without a shadow 
(which looks weird) or having the small white band above my custom window 
buttons (which also looks weird).

But for me to be able to ignore this, I'm probably going to need to prove 
something along the lines of "this is normal Windows behavior, not a bug in my 
application". But after light testing with other applications, as well as the 
simple application I uploaded here, it appears that this might be a Qt/Windows 
problem, not necessarily "all Windows applications do this".

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Click and hold on close button

2019-08-28 Thread Murphy, Sean
> I would just tell the user that it behaves like notepad and 99% of other
> Windows applications.

That's just it, I'm not sure that it does work like other Windows applications 
that don't use Qt. I just tried both Chrome and Windows Media Player and they 
do NOT exhibit that behavior. For Chrome, if I go to a website that has 
animations then do the click-and-hold sequence, the animations continue to 
play. Similarly, Windows Media Player will continue to play the movie while 
going through those steps.

I'm not sure how you would test whether it works with Notepad? I just tried it 
there, and all I can see is that the cursor stops blinking while going through 
the click-and-hold sequence. Microsoft Outlook behaves similarly. But I guess I 
can't tell if the cursor stops blinking because that application's event loop 
is blocked, or if it's because the widget with the cursor is losing focus as 
I'm clicking on one of the window control buttons.

So it seems to be a mixed bag, although it's tough to be sure what I'm testing 
since it's not like I have access to those applications' source code.

Sean  


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Click and hold on close button

2019-08-27 Thread Murphy, Sean
One of my users reported an issue that I think falls into the 
"nothing can be done about it" category, but wanted to see 
if anyone had any ideas.

On a Windows build of our application, if the user clicks 
AND HOLDS the mouse on any of the Windows buttons (so 
the standard Windows Minimize, Maximize, and Close buttons) 
the application's event loop apparently is blocked until the 
mouse is released. This happens whether it's the QMainWindow 
window, or any currently shown dialogs.

The same application on Linux does not behave this way - at 
least on Elementary 5.0, I certainly haven't exhaustively gone 
through all flavors of Linux. But at least on that version of Linux, 
the user can click and hold the window close button and the 
application still updates the UI while the mouse button is pressed.

I've attached a sample application below that can be used to test. 
When you build and launch it, a QLabel blinks between green and 
"normal", switching palettes every second. On Windows, if you 
click and hold on any of those 3 buttons, and while holding the 
mouse, move off the original button so that the release event 
doesn't happen on the same button, the blinking will cease the 
entire time you have the button pressed. Do the same thing on 
Linux and the QLabel keeps blinking happily the entire time.

Sean




This message has been scanned for malware by Forcepoint. www.forcepoint.com
<>
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Creating a custom window issues

2019-08-19 Thread Murphy, Sean
I'm having a bit of an issue creating a custom window with the 
following requirements:
1. Customized window control buttons
  a. I want to keep the 'X' button to close the window,but I do not 
  want the minimize or maximize buttons shown
  b. In addition, I then need to add my own custom button(s)
2. The window should retain the normal window shadow effect

Two satisfy requirement #1a, I first tried:
  setWindowFlags(Qt::CustomizeWindowHint |
   Qt::WindowCloseButtonHint);

That seems to get rid of the minimize & maximumize buttons, 
but I don't see any way to then add my own customized button 
to the left of the close ('x') button. Please correct me if I'm wrong 
on that count, since if there's a way to add custom buttons to 
that bar, I'd probably be all set, and everything I'm about to say 
below goes away.

Assuming there isn't a way of adding a custom button, I then 
went down a path of using:
 - setWindowFlags(Qt::FramelessWindowHint | Qt::CustomizeWindowHint);
 - create my own fake title bar widget and adding my own 
   custom buttons that, one of which looks like the standard close button 
The issue with this is that by setting Qt::FramelessWindowHint, the 
window shadow disappears.

So then I tried removing the Qt::FramelessWindowHint flag. 
This brings back the window shadow, but it also adds a small white band 
above my button bar widget.

You can see what I'm talking about here: 
https://imagebin.ca/v/4s4QprMkIsvD. The left side of that image 
shows what my window looks like with the Qt::FramelessWindowHint 
enabled. It shows there is no drop shadow (which is bad), but  also 
no excess whitespace above my fake title bar (which is good). The right 
side of the image shows the result without setting the Qt::FramelessWindowHint
flag. In that instance, the drop shadow is present (good), but I've suddenly got
excess whitespace above my fake title bar (bad). It appears the 
whitespace is about 6 pixels high.

What I want is a combination of both - no excessive whitespace, 
but with the drop shadow. Is there some way to get rid of that 
excess whitespace?

Sean



This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Finish QLineEdit editing when user clicks anywhere outside the QLineEdit

2019-08-14 Thread Murphy, Sean
> Ah. In our case, the QLineEdit is inside (and parented by) a widget that
> provides the background of the window. That parent widget can accept
> focus, so I guess our cases are not quite the same.

Ok, good! I thought I missed something. In my case, that is a problem since the 
user can click anywhere, including widgets that don't accept focus. And to make 
my custom line edit class portable, I shouldn't know or care anything about 
what other widgets are out there in the entire application.

I'm going down a path that seems to be working so far - using an event filter 
installed on the qApp instance that looks for mouse clicks and reports back to 
the line edit whether the click occurred within the line edit or not. If it is 
within, I just let QLineEdit handle it normally, if it's outside, then I finish 
editing. I still need to test more, but so far it's looking like what I want to 
do.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Finish QLineEdit editing when user clicks anywhere outside the QLineEdit

2019-08-13 Thread Murphy, Sean
> Hmm, about that extra step, to remember the filter stuff, since you already
> have a custom line edit class, why not embed the MouseFilter class inside it?
> I mean, the filter does not have to reside in MainWindow, it needs only the
> qApp pointer, so you could wire it up in your custom line edit's ctor instead.
> Thus making it an integrated part of your custom class :-)

Already planning on attempting that once I can get back around to this issue! 
As often happens, something else is pulling my attention away at the 
moment, but I'll give it a shot when I have time and report back.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Finish QLineEdit editing when user clicks anywhere outside the QLineEdit

2019-08-13 Thread Murphy, Sean
> Hi, had a similar problem, couldn't find any other solution than using an
> event filter, but it turned out being not so bad, made a small class:
> 
> In my MainWindow I have an instance of that class, and in MainWindows's
> ctor I initialize it:
> 
> MouseFilter mf;
> ...
> mf.setWidget(ui->lineEdit);
> qApp->installEventFilter();

Thank you. I was going down this path as well, that I might have to do it as an 
event filter installed somewhere up the hierarchy, instead of just being able 
to do it within a custom class that inherits from QLineEdit. So far I haven't 
found a way to do that.

And you're right, it's not so bad to do it via an event filter, but it's just 
one 
extra step I have to remember to do, every time I want to re-use this 
custom line edit, either within this application, or in other applications.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Finish QLineEdit editing when user clicks anywhere outside the QLineEdit

2019-08-13 Thread Murphy, Sean
I'm trying to create a custom QLineEdit where while editing, the user can click 
anywhere *outside* the QLineEdit to finish editing.

The default QLineEdit behavior appears to be that once the user has clicked 
inside the QLineEdit and begins editing the text, if the user then clicks on 
some other widget that *will* accept focus via a mouse click, the editing 
finished signal is emitted and the cursor/focus moves to whatever they clicked 
on. What I'm struggling with is that if the user clicks on something that 
*doesn't* normally accept focus via a mouse click, like any whitespace in my 
app, the cursor stays within the QLineEdit and editing is still active.

I thought maybe I could use focusOutEvent(), but in the case where the user 
clicks on whitespace, the QLineEdit doesn't receive a focusOutEvent(). So that 
doesn't appear to be useful, unless I'm missing something.

Ideally I want a solution that is completely contained within my custom 
QLineEdit-inherited class - with all the other widgets unaware that this 
behavior is happening. The only solution I'm finding via Google is doing things 
like installing event filters or setting the focus policy on other widgets to 
then force the QLineEdit to give up focus or end editing.

Sean 




This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] ** Caution Message may be spoofed ** Re: Zooming with QGraphicsView/QGraphicsItem

2019-08-09 Thread Murphy, Sean
> So using QGIS to convert my .shp files to .svg, and then loading the result 
> in a
> QGraphicsSVGItem works like a charm - thanks! The only drawback I’m seeing
> is zooming performance. It *looks* good, but is a tad sluggish. When using 
> QGIS, I noticed that it was compiled against Qt as well, but when they zoom,
> the actual image redraw is delayed until the zoom is complete. That is, when
> zooming in, things get pixelated until you pause, whereupon they are re-drawn
> correctly. When zooming out, areas that were outside the window remain empty
> until you pause, at which point they are drawn. The end result is that things 
> look
> worse when zooming, but zoom performance is lag-free. Is this behavior easily
> obtainable, such as through a setting on the QGraphicsSVGItem or perhaps the
> QGraphicsView, or is QGIS doing something completely different, such that I
> would have to do a lot of re-implementation to accomplish said effect?

It sounds like their strategy is something like this: when the initial image is 
loaded 
(or when the user stops zooming), they show that image and they also make a 
raster 
version of it. Then as the user requests a zoom, they instantly 
rescale/resize/crop 
the raster image to present the pixelated (on zoom in) or the empty areas (on 
zoom out) versions. At the same time they start a timer, if the user continues 
to 
zoom before that timer expires they just keep working with the raster image and 
keep resetting the timer. Only once the timer expires (which is when the user 
stops zooming) do they actual do the real zoom and redraw the scene at the new 
desired resolution. This should give you faster speed, while not having you go 
through all the work of the intermediate zoom levels - you'll only have to 
generate 
the final zoomed scene for each zoom sequence.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Automatically resize widget based on a child table's size

2019-07-19 Thread Murphy, Sean
I'm trying to create a widget with the following setup (this is related to my 
popup window question last week):

Widget hierarchy
popupWindow - unparented, top level window
 - QVBoxLayout
   - genericWidget (in my case it's a QGroupBox, but it could be any type of 
widget in theory)
   - QTableView

The QTableView is configured with both resizeRowsToContents & 
resizeColumnsToContents. My goal is that I want the popupWindow to 
automatically resize itself to be JUST BIG ENOUGH to show the QGroupBox and the 
entire QTableView without scrollbars if possible, up to a certain maximum 
popupWindow size, at which point the popupWindow doesn't get any larger and the 
table has to show scrollbars. 

I set the popupWindow's maximum size based on the user's desktop/application 
geometry to limit the popupWindow to something that looks reasonably like a 
popup - not something that would take up the full screen. But from one popup 
event to the next one, the underlying table data may have completely changed, 
which in turn causes the minimum table size required to keep the scrollbars 
hidden to change from one showing to the next. The issue I'm having is because 
the table is HIDDEN when the data is swapped out any queries I'm doing on the 
table's size don't seem to be accurate before I actually show it, but I want 
the popupWindow to show only once and already be sized correctly without any 
flicker. 

So the basic algorithm is always:
1. popupWindow has a maximum allowed size, sizeMax
2. popupWindow (and children) are hidden
3. table data changes
4. compute ideal table size to show all data without any scrollbars, sizeIdeal
5. calculate actualSize by comparing ideal size to max size, and picking 
minimum of each dimension:
actualSize.setWidth(sizeIdeal.width() < sizeMax.width() ? sizeIdeal.width() 
: sizeMax.width())
actualSize.setHeight(sizeIdeal.height() + groupBox.height() < 
sizeMax.height() ? sizeIdeal.height() + groupBox.height() : sizeMax.height())
6. Set popupWindow's fixed size to actualSize
7. Show popupWindow at correct size

It's step 4 that I'm having trouble with... I feel like I'm just not combining 
size policies correctly to get the behavior I'm looking for
Sean

P.S. Here's an example with numbers: say the groupBox's minimize size is 100 x 
50 and the maximum allowed size for the popupWindow is 600 x 800. Then the 
following sequence of popups occurs:

First popup
 - the data set populating the table needs 300 x 250 to show all contents 
without scrollbars
 - popupWindow should resize itself to be 300 x 300 (required table width x 
(minimum table height + groupBox height))

Second popup
 - the data set populating the table would need 1000 x 1200 pixels to show 
contents without scrollbars
- popupWindow should resize itself to be 600 x 800 (maximum allowed popup size) 
which means the table is clipped in both dimensions and therefore shows 
scrollbars in both dimensions

Third popup
 - the data set populating the table needs 400 x 780 pixels to show contents 
without scrollbars
 - because of the groupBox minimum height of 50, our ideal popupWindow height 
would be 830, but that exceeds the 800 pixel limit 
 - popupWindow should resize itself to be 400 x 800 (minimum table width x 
maximum allowed popup height) and the table shows a vertical scrollbar to 
accommodate the clipped height. Actually I guess the popupWindow would resize 
itself to something like 420 x 800 to allow 400 pixels for the table data and 
20 pixels for the vertical scrollbar's width.

Fourth popup, we return to the same data set as the first popup
 - the table only needs 300 x 250 to show contents without scrollbars
 - popupWindow should resize itself to again be 300 x 300 





This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Receive key presses when hovering over a specific widget

2019-07-11 Thread Murphy, Sean
> AFAIK, the easiest way to trap keyPress/keyRelease irrespective of which
> widget has the focus is to install an event filter on the QApplication
> instance.  Use the mouseEnter/Leave events of the thumbnails to set/clear a
> currentThumbnail, and then in eventFilter only act on the 'm' keyPress if the
> currentThumbnail has been set, and return false from the filter, otherwise
> return true so that the 'm' will go to the edit box or whatever.

I had pretty good luck with the following setup (example attached).
In the thumbnail class I override these functions and added the described 
behavior
in addition to letting the base class handle the rest of the behavior:
 - enterEvent() - in here I call grabKeyboard()
 - leaveEvent() - in here I call releaseKeyboard(), as well as emit a "hide 
popup" signal
 - keyPressEvent() - in here I emit a "show popup" signal only if the pressed 
key matches 
   my target (in this case the 'm' key)
 - keyReleaseEvent() - in here I emit a "hide popup" signal only if the 
released key matches 
   my target (in this case the 'm' key)

Then in the parent container class, I have show/hide popup slots connected to 
the 
show/hide signals of each thumbnail object. By doing it this way I keep the 
MainWindow class, QApplication class, etc. out of the loop since they don't 
really have anything to do with the functionality I'm looking for, so I like 
the 
way it's working so far - it better encapsulates the functionality within the 
classes that
care about it.

The attached example creates 3 thumbnail widgets each with a different 
background color, as well as a line edit that has focus to start. Pressing the 
'm' key (or any other key) will type in the line edit UNLESS you move the 
cursor over any one of the 3 thumbnails. In which case, pressing the 'm' 
key will popup a new widget that has the same background color as the 
thumbnail you were hovering over, so I think it's behaving the way I want, I 
just 
need to roll it all into my actual application.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
<>
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Receive key presses when hovering over a specific widget

2019-07-11 Thread Murphy, Sean
> Not sure if this fits your use case 100%, but might give you some ideas. I 
> did 
> something similar for magnifying images in QLabels, but I don't have your 
> additional focus issue

Yeah, that's the part I'm struggling with at the moment, but I only started 
messing with this late yesterday

> On the thing being magnified (QLabel-derived class holding the image):
>
> - holds a pointer to the magnifier and sets itself as the target of the 
> magnifier
> - in the keyPressEvent I look for Qt::Key_M and tell the magnifier it's 
> active 
> (which shows it)
> - in the keyReleaseEvent event I tell the magnifier it's not active (which 
> hides it)

So here you're using keyPressEvent()/keyReleaseEvent() on the label derived 
class correct? Just making sure I'm following which widget you're talking about

> - (for your case you might need to use enter/leave events to intercept the 
> keyboard? or maybe QWidget::underMouse()?)

I think I will need to do that, and I wasn't doing it yesterday. So what I 
tried 
yesterday was just overriding the label's keyPressEvent/keyReleaseEvent 
functions. 
That only working if I clicked on the custom label class first, at that point 
keyPressEvent/keyReleaseEvent was getting triggered, and I able to watch for 
the 
assigned key. But at application launch, if I didn't click on the label, 
instead just 
mousing over it and then pressing a key, the label never received press/release 
events.

>
> In my magnifier class (QWidget-derived):
>
> - it draws itself using info from the target widget
> - installs an event filter on the target
>   - handles mouse move to update the location/contents
>   - handles enter and leave events to show/hide itself by checking the mouse 
> location against the target widget using QCursor::pos() (note that 
> QWidget::underMouse() will not work because the mouse may be over the 
> magnifier)
> - also need to set some flags & attributes:
>   setWindowFlags( Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint );
>
>   setAttribute( Qt::WA_ShowWithoutActivating );
>   setAttribute( Qt::WA_TransparentForMouseEvents );

I'll check all that out. At the moment, my label class doesn't have access to 
the 
full data. I should come clean and say that my actual setup isn't exactly what 
I've posted here, I contrived an example that everyone could understand 
without getting bogged down in what I'm actually doing, but I think I should be 
able to massage the concept enough to make it work. For other reasons, I want 
to keep the full data set stored by the label's parent, but I could probably 
easily
just pass a pointer down to the label that gives it access to the portion of 
full data.

> I found it pretty tricky to get working (and I still have a couple of things
> I'm not happy with) but it's very close (shippable!).

What other things are you still not happy with? I'll keep an eye out for them 
and 
if I encounter them too, and solve them, I can feed that back to you.

Thanks for the pointers!
Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Receive key presses when hovering over a specific widget

2019-07-11 Thread Murphy, Sean
I'm trying to figure out the best way to receive key presses when the user 
hovers over a specific widget, and deliver that keypress information to the 
parent widget.

Say I've got three types of widgets:
1. thumbnailWidget - displays a low resolution version of a full resolution 
image, essentially based on QLabel
2. imageLibraryWidget - displays 1-N image thumbnail widgets. This widget is 
based on QWidget. Also owns all the full resolution images used to create the 
thumbnails
3. magnifierWidget - popup widget that displays a full resolution subset of the 
thumbnail. Think of it as just a magnifying glass that you can put over a 
portion of the thumbnail

Application hierarchy is as follows:
- MainWindow
- multiple "other" widgets, some of which can receive keyboard focus 
(QLineEdits, QTextEdits, etc.)
- one or more imageLibraryWidgets
- multiple "other" widgets, some of which can receive keyboard focus
- one or more imageThumbnailWidgets
- one magnifierWidget

So the way I want this to work is that when the user hovers over a thumbnail 
widget AND presses a specific key, the imageLibraryWidget that is the parent of 
that thumbnail is notified that the correct keypress has been received, and 
knows which thumbnail (and which pixel of that thumbnail) the cursor is over. 
It then will popup the magnifierWidget with the appropriate full resolution 
pixels. When the user releases the key, or moves the mouse so they are no 
longer over a thumbnail, the magnifier is hidden.

I've got the mouse position portion taken care of, but I'm struggling to get 
the key press thing correct, especially given that other widgets (either child 
widgets of the imageLibraryWidget or children of MainWindow) might have the 
keyboard focus at the time the user moves the mouse over a thumbnail and 
presses the bound key. I still want the magnifier idea to work, ideally without 
changing the keyboard focus from the currently focused widget.

So the following should work:
1. User starts to type something in a line edit
2. Before finishing what they're typing they decide they need to double check 
something in the related image
3. User move cursor over image, and presses the key bound to the magnifier 
functionality. Let's say the key is 'm'
4. While over the image, and they are holding down the 'm' key, the keypress 
should be consumed and not get entered into the line widget

That's the ideal case, I can live with it if the user would lose keyboard focus 
in the line edit and has to click back in it after the above sequence if I have 
to.

Thoughts about how to go about this? I think I might need some combination of 
event filters and QHoverEvents, but not sure of the right combo at the moment.
Sean





This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Tear off tabs similar to Chrome

2019-07-03 Thread Murphy, Sean
I'm assuming someone has already done this with Qt, but either I'm wrong or I'm 
googling poorly today... I'm just trying to find if someone has already 
implemented the functionality that Chrome (and other applications with tabs) 
where you can select a tab on the tab bar, start dragging it, and when you get 
far enough away, it'll pop off the original tab bar and become its own window. 
I've found a couple of outdated examples, that don't really work. 

Anyone already solved this?

Sean




This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Operator QMap[] is casting to int?

2019-05-03 Thread Murphy, Sean
> Unless Qt supports negative indexes (like python's [-1]) I would have thought
> this would be an int. Thanks for catching that everyone.

I'm assuming you made a typo there and meant to say "uint"? Regardless here's
the official reason why Qt uses "int" for container indices:
https://lists.qt-project.org/pipermail/interest/2013-September/008592.html

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Operator QMap[] is casting to int?

2019-05-03 Thread Murphy, Sean
> uint foregroundPixels = reverseKeys[foregroundIndex];
> uint foregroundColor = reverseKeys[foregroundPixels]; //main.cpp:66:37: 
> warning: implicit conversion changes signedness: 'uint' (aka 'unsigned int') 
> to 'int'
> 
> Where is the "signed" conversion happening?

foregroundPixels is a uint.
reverseKeys is a QList.

The QList subscript operator takes an int for the index 
(https://doc.qt.io/qt-5/qlist.html#operator-5b-5d), but you're passing it a 
uint.
Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] How to properly show progress for a signal processing pipeline

2019-04-08 Thread Murphy, Sean
> I would just show one progress set to 3 * raw count.  Each stage
> periodically signals to the ui thread its progress, and whether it has
> processed the end-of-data signal from the previous stage.  In the ui
> thread slot:
> 
> int totalCount, rawCount;
> 
> QVector stageProgress;
> 
> void stageProgressSlot(int stageIndex, int count, bool completed) {
> 
>      Q_ASSERT(count <= rawCount);
> 
>      auto thisCount = (if completed ? rawCount : count);
> 
>      Q_ASSERT(thisCount >= stageProgress[stageIndex]);
> 
>      totalCount += thisCount - stageProgress[stageIndex];
> 
>      stageProgress[stageIndex] = thisCount;
> 
>      ui->progress->setValue(totalCount);
> 
> }
> 
> It will always appear to start slowly then jump forward depending on the
> degree of filtering.  I can't see a way to avoid that other than Bill's
> idea.
> 
> Hope that helps,  Tony

I think it does, thank you. I can't really see any other way to do it to 
provide a somewhat meaningful progress bar - I'd like to avoid the
"busy" progress bar if possible since that doesn't offer the user any sort
of sense of how much longer they have to wait and your idea at least
gives them some sense of status, even if it's not 100% accurate at all times.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] How to properly show progress for a signal processing pipeline

2019-04-08 Thread Murphy, Sean
We have a data processing pipeline that looks like so:
Raw Data objects -> Type "A" data objects -> Type "B" data objects -> Final 
Data objects

Each step can be considered a filtering process where the following 
mathematical relationship holds for the quantities of each type of object:
Raw count >= A count >= B count >= Final count
Technically all of those quantity relationships can be >=, but in practice they 
almost never equal, the left hand side is almost always greater than right hand 
side, but it's technically possible that some could be equal with the right 
input data.

 So the issue I'm having here is that I want to show the user some sort of 
progress indicator (this whole pipeline takes a bit of time), but at the start 
I only know the raw count, not any of the intermediate or final counts. And 
because the A->B->Final portion of the pipeline takes a noticeable amount of 
time, I can't just run the progress bar from 0 to Raw count, because then from 
the user's standpoint the progress bar would reach 100% once the number of raw 
samples is exhausted, not when processing is fully complete.

Is my only strategy to use the "undetermined state" of QProgress bar to just 
show "something" is happening, but not how far along we are in the process? To 
make the issue even a little more complicated, each processing node is running 
in a separate thread, so these conversions are happening in parallel as much as 
possible, making tracking a little more difficult. For example, at any given 
point in time, the node that converts type A objects to B objects, might be 
empty. It may have processed all of the A objects it has received into all the 
B objects it can make and passed them on to the next node, while the node ahead 
of it might not have finished its work on the next chunk of raw data to emit 
the next A object. So at that instant in time, the A->B node thinks it's "done" 
until it receives the next A object at some time later.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QTabWidget scroll buttons

2019-03-26 Thread Murphy, Sean
> > there doesn't appear to be an easy way to add widgets in the tab widget's
> tab bar.
> 
> QTabWidget::tabBar(), layout(), addItem() ?

I meant "easy" in the sense of a functions like these (which don't exist):
  QToolButton* QTabWidget::leftScrollButton()
  QToolButton* QTabWidget::rightScrollButton()

Unless I'm missing something, both your tabBar()->layout()->addItem() 
suggestion and your previous email about drilling down and finding the
QToolButton children aren't part of the QTabWidget documented API, 
which means they could change how those are implemented in a 
future version of Qt.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QTabWidget scroll buttons

2019-03-26 Thread Murphy, Sean
> This works for me, and the button is small 16x16.
> 
> m_TheTabWidget->setCornerWidget(bp1);

You know, I saw that function and for some reason switched it
in my head to be talking about the corner cell in a QTableWidget, 
not talking about a QTabWidget. Apparently I need more caffeine
today...

Thanks, I'll give this a try!
Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QTabWidget scroll buttons

2019-03-26 Thread Murphy, Sean
> You could add a tool-button with said popup menu associated to it to the
> right of the tab widget (e.g. Firefox does this). This would have the
> advantage from my PoV that it's always there and works, regardless of
> how many tabs are open.

I'll ask whether this would be acceptable. As I mentioned in response to
William Crocker, I'm currently losing the battle that the requested idea is
a bad idea.

One issue with the tool button idea will just be finding an acceptable location
for it. There are already other widgets surrounding the QTabWidget in our UI,
so squeezing it in without having to rearrange everything else could be an 
issue.

Honestly, an decent solution would be where if I could modify the tab widget's
tab bar to never show the scroll buttons (easy enough with the usesScrollButtons
property), and instead always show the tool button. This looks harder though 
since
there doesn't appear to be an easy way to add widgets in the tab widget's tab 
bar.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QTabWidget scroll buttons

2019-03-26 Thread Murphy, Sean
> > A request has come in to allow the user to right-click on the scroll 
> > buttons,
> which would then open a popup menu of all open tab names which they can
> select from, and then I could just set the selected tab as the currentIndex().
> But I don't see anything on https://doc.qt.io/qt-5/qtabwidget.html that talks
> about those scroll buttons beyond just the usesScrollButtons property. So
> I'm not sure how to specifically trigger off from a right click on the scroll
> arrows themselves...
> >
> 
> What will that pop-up menu look like if there are 100 tabs open.

I 100% agree with where you're headed with that question. I don't like this
idea for a multitude of reasons: 
- the tabs tend to have long filenames, so not the sort of thing that fits 
nicely in 
  a popup, even if there aren't many of them
- the quantity issue you brought up
- I don't think many people would expect that you could right-click on one of
  those buttons to bring up a contextual menu from a UI design perspective

That being said, right now the request is the request so even though I've raised
my objections to it, I'm still tasked with fulfilling it at this point...

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] QTabWidget scroll buttons

2019-03-26 Thread Murphy, Sean
Is there a way to get access to the scroll buttons on a QTabWidget to customize 
them?

The issue we're having is that we have a UI that uses a tab widget for 
displaying file contents - one tab per open file. Once a user opens enough 
files/tabs, the tab scroll buttons pop up (so far so good), but then the user 
keeps opening more tabs. Eventually they have enough open that it can take 
quite a while to navigate between open tabs since each click on a scroll button 
only shifts the visible tabs over by one tab per click. For example, if they 
have 10 tabs open, and because of screen size, tab elide mode, etc., they can 
only see 3 tabs at a time, if they are currently looking at the 10th tab, but 
want to then go view the 1st, they have to click 7 times to get over to the 
first tab.

A request has come in to allow the user to right-click on the scroll buttons, 
which would then open a popup menu of all open tab names which they can select 
from, and then I could just set the selected tab as the currentIndex(). But I 
don't see anything on https://doc.qt.io/qt-5/qtabwidget.html that talks about 
those scroll buttons beyond just the usesScrollButtons property. So I'm not 
sure how to specifically trigger off from a right click on the scroll arrows 
themselves...

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Issue using QSettings INI format on Windows

2019-02-08 Thread Murphy, Sean
> Well there's always QSettings::registerFormat (
> https://doc.qt.io/qt-5/qsettings.html#registerFormat )
> 
> Haven't tried it myself but it will give you a QSettings::SettingsMap
> which means you'll still have to serialize out it yourself to a QString,
> but at least you can get rid of the file i/o by ignoring those
> QIODevices that QSettings hands over. /Rgrds Henry

I didn't notice that one. That might work for our needs, I'll have
to play around with it...

Thanks (twice now!)
Sean



This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Issue using QSettings INI format on Windows

2019-02-08 Thread Murphy, Sean
> Hi, just tested your example program in MSVC 2017 Qt 5.12.1 and it fails
> as well.
> 
> But a simple fix is just to make sure that the QFile file isn't open at
> the same time as you write out the settings to it.
> I.e. in your example program, it suffices to move that first
> file.close(); up to just before the "// write out via QSettings" comment
> line is, then it runs flawlessly.
> 
> But perhaps that's not possible to keep those writes separate in time in
> your "real" app that your porting?

Thanks for testing!

Yes, I discovered that issue as well, and then forgot to post a follow-up 
here. Where I had trouble, and something I did differently in the real 
app vs. the minimal example, is that the file I was trying to use to write 
the settings to was a QTemporaryFile. I stumbled across the same fix you 
did in the example, but that fix never seemed to work in my real app with a 
QTemporaryFile. After testing, I believe that is because the QSettings 
object is trying to open the associated settings file with write permissions, 
and it isn't able to acquire them. In my example, it was because I already 
had opened the file with write permissions (mistakenly thinking I needed 
to do that before all the QSettings stuff). In my real app, I think that it 
must be because QTemporaryFile holds a lock on the file so it can 
remove it when the QTemporaryFile object goes out of scope, and 
therefore the QSettings object gets an access error because the file is 
already in use. 

What I'm actually trying to accomplish is far more simple: I don't actually 
want an INI file, I just want to get data that I've put into a QSettings object 
written to a QString, in the INI file format. I couldn't see any other way to 
do that than to write it out to a file, then read the file contents back into 
a QString. So if you see a simpler solution for that, I'm open to suggestions! 

In my real app, I've solved it by using removing the QTemporaryFile 
object, and just letting QSettings do its thing, writing to a file. Then when 
the file has been written, I read it back in to a QString, and delete the file 
since I have no further use for it.

Sean




This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Issue using QSettings INI format on Windows

2019-02-08 Thread Murphy, Sean
I'm porting an old application from Qt 5.3.2 to Qt 5.9.6 (yeah, I know, we're a 
lot behind...). I'm running into an issue where code we had that was writing 
out settings via the QSettings constructor that takes a file name doesn't work 
anymore. I've attached a fairly minimal example that shows this.

What I've found so far:
- this code works perfectly on Windows using Qt 5.3.2 (mingw 4.8.2)
- this code works perfectly on a Mac using Qt 5.9.6 (clang)
- this code fails on Windows using Qt 5.9.6 (mingw 5.3.0)

Anyone have any ideas?

Sean 



This message has been scanned for malware by Forcepoint. www.forcepoint.com
<>
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Struggling with moveEvent()

2018-10-03 Thread Murphy, Sean
> > Regarding your setMenu question, I did consider it, but I didn't think it 
> > would
> > work for my needs - although I could be wrong about that. Here's my 
> > requirements:
> > 1. I need a widget that pops up when the user clicks on a button So this 
> > requirement
> >  *could* be handled by QPushButton::setMenu(), but I believe it's the 
> >subsequent 
> >  requirements that get me into trouble
> > 2. I want the popup to have a "caption bubble" look to it as shown here 
> >  https://imagebin.ca/v/4Hi83WgTMrmp where the little triangle is lined up 
> >  with and touching the pushbutton that was pushed to trigger this menu 
> >being shown
> > 3. I want the "menu" to allow me to put my own interactive widget in it, 
> > not just
> >  QAction-based menu items. For example, one pushbutton will allow the user 
> >to 
> >  select a color from a color picker. So clicking that pushbutton should pop 
> >up a "menu" 
> >  that looks like this https://imagebin.ca/v/4Hi9KpUg8Vk8 where there are no 
> >menu 
> >  items like you'd normally find on a QMenu, just the color picker that the 
> >user can interact
> >  with
>
> I'm not sure about #2, but I think you should be able to implement what you 
> want by 
> creating a QMenu which has a single action. The action would need to be a 
> QWidgetAction, 
> not a regular QAction. Your QWidgetAction would provide a widget to do the 
> actual 
> color picking.  We do this in our application.

This looks promising - I had never stumbled across QWidgetAction before. 
Although now 
that you point it out, I've discovered the section of the QMenu documentation 
that I 
previously skimmed over that mentions it!

Is the code in your paintEvent() something you can share, if there's anything 
noteworthy
happening in there?

Sean



This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Simple device discovery using UDP

2018-10-02 Thread Murphy, Sean
> I have an app (Desktop) that I want it to know about other running instances
> on the local network. I figured UDP broadcast was a natural choice. I tried 
> it,
> but I never saw anything but my own (local) packets. There's quite a few
> stackoverflow questions, but none used Qt. I'm wondering if it's a wifi/router
> thing?

A couple of first questions: 
- do you have any sort of firewalls running anywhere?
- have you tried the Qt Networks examples, and do those work?
  http://doc.qt.io/qt-5/qtexamples.html#qt-network, maybe the Broadcast
  Sender & Receiver examples

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Struggling with moveEvent()

2018-10-02 Thread Murphy, Sean
> Widgets are normally positioned relative to their owner - the exception
> is popup menus, which are screen absolute.  I would expect a popup menu
> to automatically close when the title bar is clicked.  How have you
> implemented your captionPopupMenu?  Does it capture the mouse when it
> is
> visible?  It should close if the mouse is clicked anywhere outside its
> borders.  Since you've got a QPushButton, did you consider using its
> setMenu to achieve a similar result?

I've come around to agree that I should just close it whenever focus leaves it,
which then means I don't need to worry about figuring out how to detect
when I need to move it.

Regarding your setMenu question, I did consider it, but I didn't think it would
work for my needs - although I could be wrong about that. Here's my 
requirements:
1. I need a widget that pops up when the user clicks on a button So this 
requirement
  *could* be handled by QPushButton::setMenu(), but I believe it's the 
subsequent 
  requirements that get me into trouble
2. I want the popup to have a "caption bubble" look to it as shown here 
  https://imagebin.ca/v/4Hi83WgTMrmp where the little triangle is lined up 
  with and touching the pushbutton that was pushed to trigger this menu being 
shown
3. I want the "menu" to allow me to put my own interactive widget in it, not 
just
  QAction-based menu items. For example, one pushbutton will allow the user to 
  select a color from a color picker. So clicking that pushbutton should pop up 
a "menu" 
  that looks like this https://imagebin.ca/v/4Hi9KpUg8Vk8 where there are no 
menu 
  items like you'd normally find on a QMenu, just the color picker that the 
user can interact
  with

Requirement 1 could obviously use a QMenu and QPushButton::setMenu(). I think I
might even be to satisfy #2 using something that inherits from QMenu and does
some additional painting to add the triangle feature where it needs to be. I 
don't 
know if I can satisfy #3 though by inheriting from QMenu? The only thing I can 
think 
of is when I want to add my custom child widget (like the color picker), that 
on those 
menus I don't add an QActions, instead adding a child widget? I haven't tried 
this route 
yet, so I don't know what I'd run into?

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Struggling with moveEvent()

2018-10-02 Thread Murphy, Sean
> > So I'm not sure what I need to trigger off from to detect when I need to
> reposition the menu. I feel like I'm missing something really obvious, but not
> seeing it on a Monday apparently.
> 
> I don't think you're missing anything -- if a widget doesn't move, but
> its parent does, only the parent gets a move event, not the widget.

Yeah, I was starting to come to this realization after I posted, by heading back
to the docs and reading what a QMoveEvent object actually is
(http://doc.qt.io/qt-5/qmoveevent.html), specifically the
line:  Move events are sent to widgets that have been moved to a new 
position relative to their parent.

> As a result, for your use case, I believe you need to track move events
> on the whole parent/child chain starting at the window up to your
> widget. I guess you can install event filters for this.

I might have to, but I definitely don't really like this solution since it 
breaks
encapsulation. What I'm looking at now is since the widget I'm popping up
is supposed to behave somewhat similar to a popup menu, that I should 
probably just hide it whenever focus leaves it. That's probably more what
users would expect to happen, and makes it easier on me anyways.

Sean




This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] Struggling with moveEvent()

2018-10-01 Thread Murphy, Sean
My basic question is how do child widgets get moved or repainted when some 
ancestor of theirs moves? 

Here's the more detailed issue, first the widget hierarchy:
QMainWindow
   CustomerHeaderTable (inherits from QTableWidget)
   CustomTableHeader (inherits from QHeaderView, allows you to put widgets 
in the header sections)
   dataConfigWidget (inherits from QWidget)
   QPushButton 
   captionPopupMenu (inherits from QWidget, starts out hidden)

What I'm trying to accomplish is when the user presses the QPushButton, that a 
custom popup menu (the captionPopupMenu) appears aligned to the pushbutton. 
Right now I've got the initial alignment working just fine. The issue is when 
the popup is visible, if the user then grabs the application title bar and 
moves the entire main window around, the popup isn't moving with the 
application. So I figured I just need to update the captionPopupMenu's position 
in dataConfigWidget's moveEvent() to keep it positioned correctly. But it 
appears when the main window moves around, the dataConfigWidget's moveEvent() 
is never called - I put some qDebug() statements in there to verify. Same goes 
for paintEvent() - my child widgets aren't getting called when the ancestors 
move. 

So I'm not sure what I need to trigger off from to detect when I need to 
reposition the menu. I feel like I'm missing something really obvious, but not 
seeing it on a Monday apparently.
Sean



This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] Stylized popup menu with caption triangle?

2018-09-28 Thread Murphy, Sean
I'm wondering if anyone knows of a Qt widget that already does this, similar to 
this javascript example I found: 
https://stackoverflow.com/questions/19089841/extjs-4-2-1-add-a-top-arrow-to-any-popup-menu

I've got a widget that has some buttons on it. When I click on one of those 
buttons, I want it to popup a menu like the example above, with the triangle 
appearing to be attached to the edge of the button that was clicked. 
Technically, I really don't want it to be a QPopupMenu - I want the popup 
behavior, but I'd rather it just be a generic container widget that I can then 
put in whatever custom widgets I want

I'm fairly certain I know how to do this from scratch if I have to (grab the 
button's geometry, place the customized popup where I want it and have its 
paintEvent() paint the triangle where it needs to be), I'm just wondering if 
someone has already done it?

Sean



This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QTreeWidget displays blank widget

2018-08-09 Thread Murphy, Sean
> Yes, I used QTreeWidget ::setCellWidget(int row, int column, QWidget *widget).
> I have already used QStyledItemDelegate, but setCellWidget is far easiest for 
> what I want to do.
> I don't really understand why QPushbutton are correctly displayed and not 
> other widgets.
> But if only delegate is the solution, I will use it.

>From the discussion I had with support, it appears that QTableWidget is 
>expecting a 
QTableWidgetItem to define the colors for QPalette::ForegroundRole and 
QPalette::BackgroundRole,
but since you're using setCellWidget() you're most likely not adding a 
QTableWidgetItem to the
cell. Which even if you were, I don't think would get what you want since you 
have two different
background colors (the orange and the blue) as the background of the two 
labels. I don't know
if using QStyledItemDelegate gets you over that hurdle either, since I don't 
see how it allows you
to set different BackgroundRole values for the QLabel child widgets?

If you come up with a good solution, please respond to the list (or at least 
respond to me personally!)
as I'm interested in the correct solution to this as well just in case we 
decide to come back around to
this idea for our project.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QTreeWidget displays blank widget

2018-08-09 Thread Murphy, Sean
> I would like to display colored widgets in a QTreeWidget.
> Screenshots of what I really have are in attached files.
> My wigdet is colored, but when in the QTreeWidget, it is all white. How can I 
> resolve it?

Are you adding your widget to the QTreeWidget via 
  QTreeWidget ::setCellWidget(int row, int column, QWidget *widget)
?

If so, I had the same issue and got this suggestion from Qt support:

"This does not look like a bug to me. The QStyledItemDelegate is the way to
customize painting the items in QTableView's (and Widgets), you can read more
about this from:
http://doc.qt.io/qt-5/qstyleditemdelegate.html#details

The Table views (and other item views) are rendered differently, so it looks
like the palette is just not used in these cases (looks like
QStyledItemDelegate does not support it). So if you want to customize the
items further, I would suggest using the QStyledItemDelegate."

We ended up changing our minds (for a different reason), and I never went
down the path suggested by Qt support, so I don't know how easy it is to
apply to what you're doing, but on the surface it sounds like what you might 
want
to do?

I personally still think it's a bug (again assuming you're using the 
setCellWidget() call),
since I think in that specific case, the QTableWidget should honor the fact 
that the 
widget you're setting within a table cell already knows how to paint itself 
fully and it's 
palette should be used.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] How to create custom chart/axis

2018-06-12 Thread Murphy, Sean
I forgot to add the sample code I have (which is modified from the BarChart 
example). In the example, I've attached two x-axis objects to the plot, a 
QValueAxis located above the plot that puts tick marks and labels where I want 
them to be, but has the wrong values, and a QBarCategoryAxis located below the 
plot that has most of the values I want (there doesn't seem to be any way to 
have N+1 labels for N bins), but the labels are centered on the bins, not on 
the tick marks...

Sean Murphy
Sr. Project Engineer
Walbro LLC
4144 Doerr Rd
Cass City, MI 48726
ph. 989 872 7274
cell 734 223 8975
fax. 989 872 3782
smur...@walbro.com<mailto:smur...@walbro.com>

Confidentiality Notice: The materials contained within this e-mail transmission 
(including all attachments) are private and confidential and the property of 
the sender. The information contained in the materials is privileged and 
intended only for the named addressee(s). If you are not the intended 
addressee, be advised that any unauthorized disclosure, copying, distribution 
or the taking of any action in reliance on the contents of this material is 
strictly prohibited. If you have received this e-mail transmission in error, 
please immediately notify the sender by telephone at 989-872-7274 or send an 
e-mail to smur...@walbro.com<mailto:smur...@walbro.com> and thereafter destroy 
the e-mail you received and all copies thereof.

From: Interest  On Behalf 
Of Murphy, Sean
Sent: Tuesday, June 12, 2018 1:45 PM
To: interest@qt-project.org
Subject: [Interest] How to create custom chart/axis


I'm trying to plot some data using QCharts and having trouble finding the 
combination of options that get me what I want, here's our setup:



Underlying data: the underlying data is basically a set of bins, with a count 
of how many items are in that bin. The numerical range of each individual bin 
is non-uniform, i.e. the range of bin 0 may or may not equal the range of bin 
1, which may or may not equal the range of bin 2, etc.



Here's an example data set:

Bin range# of items in bin

0-700   1

700-12002

1200-1800   3

1800-2800   4

2800-3800   5

3800-4200   6

So what you can see here is that there are 6 bins total, but there are 7 bin 
edges: 0, 700, 1200, 1800, 2800, 3800, 4200.



Desired plot characteristics: we want the pixel width of each bin to be uniform 
regardless of the numerical range of the bin. We need to have the x-axis tick 
marks and labels correctly show the values of the bin edges. I've attached a 
photoshopped picture of the desired plot, you can see that the bins are all of 
equal pixel width, and that I've photoshopped the labels I want on the x-axis.



Trying to create this using QChart classes seems to be a problem.

1.   To get the bin spacing to be uniform, the best way to plot the data is 
to have the x values be 0,1,2,3,4,5 and the y values be the number of items in 
the bin (1,2,3,4,5,6).

2.   Based on where I want the labels, QValueAxis seems closer to what I 
want because it puts the labels on the tick marks, and allows for the number of 
tick marks to be one greater than the number of bins, however there doesn't 
seem to be a way to have the axis's labels be values that aren't equal to the 
value of the tick mark in plot values.

3.   QCategoryAxis (or QBarCategoryAxis) allow you to customize the string 
for each label, but seems to lock you in to number of labels equals number of 
bins.

There doesn't seem to be an axis type that allows all of the above to coexist 
at the same time.



So then I took a look at QAbstractAxis, wondering if I can create my own. The 
issue there is I don't see any way to override the text of an axis label or to 
get a pointer to any of the labels, etc. Is there any way to do this?



Sean


This message has been scanned for malware by Forcepoint. 
www.forcepoint.com<http://www.forcepoint.com/>


Click 
here<https://www.mailcontrol.com/sr/iDHNIolXV47GX2PQPOmvUlHUcPnZ!qyDfNqCk519TFZ5PGFCHLa9YuAHHz0VcbnSJu!Oqka8PlrJaydNu2tBwg==>
 to report this email as spam.


barchart.pro
Description: barchart.pro
/
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Charts module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General 

[Interest] How to create custom chart/axis

2018-06-12 Thread Murphy, Sean
I'm trying to plot some data using QCharts and having trouble finding the 
combination of options that get me what I want, here's our setup:



Underlying data: the underlying data is basically a set of bins, with a count 
of how many items are in that bin. The numerical range of each individual bin 
is non-uniform, i.e. the range of bin 0 may or may not equal the range of bin 
1, which may or may not equal the range of bin 2, etc.



Here's an example data set:

Bin range# of items in bin

0-700   1

700-12002

1200-1800   3

1800-2800   4

2800-3800   5

3800-4200   6

So what you can see here is that there are 6 bins total, but there are 7 bin 
edges: 0, 700, 1200, 1800, 2800, 3800, 4200.



Desired plot characteristics: we want the pixel width of each bin to be uniform 
regardless of the numerical range of the bin. We need to have the x-axis tick 
marks and labels correctly show the values of the bin edges. I've attached a 
photoshopped picture of the desired plot, you can see that the bins are all of 
equal pixel width, and that I've photoshopped the labels I want on the x-axis.



Trying to create this using QChart classes seems to be a problem.

1.   To get the bin spacing to be uniform, the best way to plot the data is 
to have the x values be 0,1,2,3,4,5 and the y values be the number of items in 
the bin (1,2,3,4,5,6).

2.   Based on where I want the labels, QValueAxis seems closer to what I 
want because it puts the labels on the tick marks, and allows for the number of 
tick marks to be one greater than the number of bins, however there doesn't 
seem to be a way to have the axis's labels be values that aren't equal to the 
value of the tick mark in plot values.

3.   QCategoryAxis (or QBarCategoryAxis) allow you to customize the string 
for each label, but seems to lock you in to number of labels equals number of 
bins.

There doesn't seem to be an axis type that allows all of the above to coexist 
at the same time.



So then I took a look at QAbstractAxis, wondering if I can create my own. The 
issue there is I don't see any way to override the text of an axis label or to 
get a pointer to any of the labels, etc. Is there any way to do this?



Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] This looks like a job for QVariants?

2018-05-23 Thread Murphy, Sean
I'm just looking for someone to sanity check my thought process here...

I've been tasked with having my application read in structs out of header files 
to
create data structures in memory that can be populated by the user. Those 
structures
which then can later be written out/displayed in a variety of ways: a packed 
binary 
format whose footprint would match the packed version of that struct as if it 
were 
compiled, displayed in the UI in human-readable values, written/read to/from 
XML 
document, etc.

The struct in question contains a combination of variables, 1D arrays, and 2D 
arrays, 
all primitive data types. The types of each of those are any combination of 
signed/unsigned,
char/short. The sizes of all arrays are variable. The number of variables, 1D 
arrays, 
and 2D arrays is also variable between different header files. I've included a 
couple of 
examples below, both of which are perfectly valid for our use case.

Example 1: three 2D arrays, two 1D arrays, three variables
typedef struct _myStruct {
  // 2D arrays
  unsigned short A[16][32];   
  unsigned short B[8][12];  
  unsigned char  C[16][16];  
 
  // 1D array
  unsigned short D[10];
  signed char E[8];
  
  // variables
  signed charF;   
  unsigned char  G;  
  unsigned short H; 
} myStruct;

Example 2: two 2D arrays, zero 1D arrays, four variables
typedef struct _ myStruct {
  // 2D arrays
  unsigned char  J[20][4];   
  unsigned short K[12][24];

  // 1D arrays

  // variables   
  signed char L;   
  unsigned char  M; 
  unsigned char  N; 
  unsigned char  O;   
} myStruct;

So when I parse these structs in, I need to keep track whether each entry was 
signed or 
unsigned, and whether it's type is char or short. My plan at the moment is to 
create a 
container class based on QVectors of QVariants that looks roughly like the 
following:

class myStructContainer {
private:
  QVector mVariables;
  QVector m1DArrays;
  QVector > m2DArrays;
};

And then use QVariant::type() when accessing them for writing/display to know 
what 
primitive data type each of those things contain.

Am I missing a better approach to this?
Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QDatastream, QMap, QImage serialization

2018-05-21 Thread Murphy, Sean
> > Why is QImage even a GUI type?
> 
> "Has pixels" is the simplest defintiion of GUI.

As a counter to that: QImage be safely used outside of the GUI thread which
is not true for most classes that are considered GUI classes...

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Possible to draw between QWindows

2018-05-01 Thread Murphy, Sean
> By definition, you can only draw inside a window.
> 
> So if you need to draw, put a window there. Maybe you can make a window
> that has no title bar, no borders and is transparent.

That was going to be my suggestion as well, and I was working on something
last week that needed a transparent overlay to draw across widgets too, so
I had this discussion bookmarked that might be helpful?

https://stackoverflow.com/questions/19199863/draw-rectangular-overlay-on-qwidget-at-click

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QTableWidget::setCellWidget() overrides widget's palette?

2018-04-20 Thread Murphy, Sean
> > But the issue only comes up with the plots that are embedded into the
> table. The standalone plot has the color palette I want, and
> > the palette is being set in the plot class' constructor, so it should be the
> same palette for all 3 plots.
> 
> Yea, didn't think that was it.
> 
> One ugly workaround I found that seems to work:
> 
> auto palette = canvas()->palette();
> palette.setBrush(QPalette::Base, QBrush(QColor(50,50,50)));
> canvas()->setPalette(palette);

Thanks so much for finding that solution! After my last email, I had tried
setting it with QPalette::Window, but didn't try Base.

> Instead of
> 
> setCanvasBackground(QBrush(QColor(50,50,50)));
> 
> Still don't understand why that won't work though.

I don't either, but at this point it works the way I want it to, so that's good 
enough
for me!

Thanks again, 
Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QTableWidget::setCellWidget() overrides widget's palette?

2018-04-20 Thread Murphy, Sean
> Probably not your problem, but have you tried setAutoFillBackground(true) on 
> your plot? I have that in one of my Qwt apps.

I think I did. I played around a lot with the following functions, but it's 
possible I didn't hit the right combination in the right location 
  QTableWidget::setAutoFillBackground(true);
  QwtPlot::setAutoFillBackground(true);
  QwtPlot::setCanvasBackground(QBrush(QColor(50,50,50)));
  QwtPlot::canvas()->setAutoFilleBackground(true);

But the issue only comes up with the plots that are embedded into the table. 
The standalone plot has the color palette I want, and 
the palette is being set in the plot class' constructor, so it should be the 
same palette for all 3 plots.

Sean





This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] QHeaderView equivalent of QTableView::setSpan?

2018-03-12 Thread Murphy, Sean
I'm trying to figure out how to have a horizontal QHeaderView's sections span 
multiple columns. I know that within the table itself, table cells can be 
merged via QTableView::setSpan(int row, int column, int rowSpanCount, int 
columnSpanCount), but as far as I can tell, that functionality doesn't seem to 
exist in the header? A quick Google points me to this 
https://stackoverflow.com/questions/22755171/spanning-horizontal-header-in-qt 
that shows an example subclassing QHeaderView - is that the only way this is 
possible?



If it matters, I don't really particularly care if I use QTableWidget or a 
QTableView. I can play with the subclassing approach if necessary, I just 
wanted to make sure I wasn't missing something obvious. It seems like this 
should be built-in, it can't be that uncommon, can it?



Other possibly relevant specifications: the table will be read only, and the 
header would have header section 0 spanning just the first column, but then 
after that each header section would span 3 table columns, i.e.



| header 0 |  header 1  |  header 2   | ...

| table 0  | table 1 | table 2 | table 3| table 4 | table 5 | table 6 | ...



Sean






This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QPainter rotate bounding rect?

2018-03-02 Thread Murphy, Sean
I didn't check to see if it's built in to Qt or not, but here's the math you 
need to make it work yourself

http://iiif.io/api/annex/notes/rotation/

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt Charts questions

2018-01-08 Thread Murphy, Sean
> The Qt Charts module is licensed under GPL, not LGPL. See: 
> http://doc.qt.io/qt-5/qtmodules.html#gpl-licensed-addons

We have a commercial Qt license, so I believe we aren't 
GPL-bound for Qt Charts (or the Data Visualization & 
Virtual Keyboard modules)? 

That link you sent says "Add-ons available under Commercial 
Licenses, or GNU General Public License v3". We operate in the
former part of that sentence. 

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt Charts questions

2018-01-08 Thread Murphy, Sean
> > I find that they work well if you're just trying to have one plot, but I'm 
> > struggling to get
> > them to work the way I need them to for our requirements:

> Are you looking for a library that you want to include into your application 
> or do you 
> simply want to visualize the data as described? If the latter is the case, 
> why not to use 
> plotting applications like Kst LabPlot, etc.? In case you need a library, 
> maybe you want 
> to check QCustomPlot - it's more powerful I think. Our plotting engine in 
> LabPlot would 
> be also able to fulfill your requirements but the code is not available as a 
> separate 
> library yet..

I'm definitely looking for a library. A huge part of the purpose of my 
application is to
talk to one of our devices, log data from it, plot it on a timeline, and allow 
the user to
access that data visually.

I had never heard of QCustomPlot before, I'm looking at it now, but if I'm 
reading their site
correctly, the licensing might not work for us - it appears to be licensed GPL 
and we'd need
something more like LGPL

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt Charts questions

2018-01-08 Thread Murphy, Sean
> As long as this isn't for printing...
> Fix 1-3 by normailizing each sensor from min to max, and plot that. This is 
> C++ so you can 
> override at() in the QXYLineSeries. You should be able to dymically change 
> the Y legend 
> when you mouse over a > specific point.

I’ll take a look at this idea, but I don’t think it’ll work for what we’re 
doing mainly because 
there’s always the possibility that two or more different series are either 
crossing or lie on 
top of each other at a specific value(s) of x and I would have no way of 
knowing 
programmatically which series the user is attempting to mouse over to pick the 
correct 
scale to display on the y-axis.
 
> I think you are correct in that there's not much documentation on how to 
> customize your 
> charts for use with QChartView, but looking at the QAbstract* classes in the 
> module, it 
> looks like they provide an abstract base class for everything you need to add 
> new chart 
> types.

I’ll take a look at this. Really, all that is required for me to get this to 
work is the ability to 
set a fixed width to the axes items, so that the width of an axis item doesn’t 
change when
 the min/max values change, as they do now.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt Charts questions

2018-01-04 Thread Murphy, Sean
> That can really distort the shape of a curve in often misleading ways.
> And if the sensors can be truly zero, you have another, bigger problem.
> 
> > On Jan 4, 2018, at 2:11 PM, william.croc...@analog.com wrote:
> >
> > Use a single, logarithmic Y axis.
> > (I have never use Qt Charts so I do not know if they support logarithmic
> axes.)

The do support logarithmic axes, but that will absolutely not work for what 
we're doing. As John mentioned, that causes its own issues. 

We need linear scaling for everything.

Sean



This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt Charts questions

2018-01-04 Thread Murphy, Sean
> I've used them. Once. 3 years ago.

Yeah, and that was sort of why I asked. Not that qt-interest would be the WRONG 
place to ask, but whether it's the BEST place to ask. Mainly because I rarely 
see any traffic about the classes in that module here.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] Custom indicator on QTableWidgetItem

2017-11-20 Thread Murphy, Sean
Some spreadsheet applications (notably MS Excel, Google Sheets, etc.) have a 
mechanism for indicating that a cell has a comment attached to it (see attached 
screenshot, the red triangle in the upper corner of the cell A1). Is there a 
way to do something similar with a QTableWidgetItem?

The only method I'm seeing at the moment is to create my own custom widget, 
like something that inherits from QLabel for example, that has this indicator, 
and then use QTableWidget::setCellWidget() to insert it where I want in the 
table. Am I missing some other method?

Other (possibly) important notes:
- the table is read-only, so I don't need to worry about making the 
QTableWidgetItem editable, so that's why my approach above suggest QLabel, not 
QLineEdit
- If there is a way to do it without a custom widget, I'd like to be able to do 
it via a custom Role (i.e. QTableWidgetItem::setData(myCommentRole, bool 
commentEnabled) ) if possible, but that's not really critical

Sean



This message has been scanned for malware by Forcepoint. www.forcepoint.com
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qml MessageDialog not centered over window

2017-09-25 Thread Murphy, Sean
> Aha, it happens when using a QApplication; the MessageDialog is actually a
> QMessageBox in that case.  I can get the same result with the test qml like
> this:
> 
> qml -apptype widget messagedialog.qml
> 
> (that makes the qml runtime use a QApplication instead of QGuiApplication)
> and maybe we have some trouble making a QWidget dialog transient for a
> QWindow.  In  QMessageBoxHelper::show(), it does try to set its transient
> parent:
> 
>  virtual bool show(Qt::WindowFlags f, Qt::WindowModality m, QWindow
> *parent) {
> m_dialog.winId();
> QWindow *window = m_dialog.windowHandle();
> Q_ASSERT(window);
> window->setTransientParent(parent);
>  qDebug() << window << "transient for" << parent;
> … }
> 
> QMessageBoxHelper::show - QWidgetWindow(0x7fcf52d80a40,
> name="QMessageBoxClassWindow") transient for
> QQuickWindowQmlImpl(0x7fcf54a192c0)
> 
> I wrote it up as QTBUG-63406.

Ok. I still need to figure out what I'm doing wrong in my application that I'm 
not able to use a QGuiApplication without getting that assert for some reason.
I really would like it to be a MessageDialog, not a QMessageBox, but as I've got
things right now, I can't seem to get QGuiApplication to work.

My application is pretty lightweight, and it is based off from the Qt Quick 
Extras -
Dashboard in the examples folder. That example runs just fine using 
QGuiApplication,
so I don't get what I've done to it that makes it assert now. I guess I need to 
start 
from the working example and begin adding in chunks of my actual application 
until
I find out what the problems is.

Sean

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


Re: [Interest] Qml MessageDialog not centered over window

2017-09-25 Thread Murphy, Sean
> Yes, it should be automatically transient for its parent.  For me it works on
> Linux and macOS.  So I wonder if we have a bug about this transient-
> parenting in general on Windows.  Have you tried any older Qt versions?

Well, the example code you sent me worked correctly on the same version 
of Qt (5.9.1) that I'm using for me real application, so I must be doing 
something else wrong. First I tried your code as-is in a brand new project. 
On first run, that had the main window show up centered in the monitor, 
and the dialog was also centered, so I couldn't tell if the dialog was actually 
being centered over its parent, or if they were both just being centered on 
my screen. So I modified Window to be
 Window {
visible: true
x: 60
y: 100
  
  }
And that worked correctly, Window is in upper left corner of my screen, 
and when the error dialog pops up it is centered over Window. 

After that, I copied your Timer object into my real application and ran it. 
That fails - my main Window object is off-center on my screen, the dialog is 
shown centered on the screen. One thing I noticed is that the error dialogs 
look different from each other, the attached images show that. The image 
"testError.png" is what I get when running your sample code in its own 
application. "actualError.png" is what it looks like when run from inside my 
actual application, so something else is going on, but I'm not sure what yet.

Other differences I can see are my imports
  import QtQuick 2.6
  import QtQuick.Window 2.1
  import QtQuick.Controls 2.2
  import QtQuick.Controls.Styles 1.4
  import QtQuick.Extras 1.4
  import QtQuick.Dialogs 1.2
  import QtQuick.Layouts 1.3
  import QtCharts 2.2

And in my real main.cpp I have
  QApplication app(argc, argv);
  QQmlEngine engine;
  QQmlComponent component(, QUrl("qrc:/qml/dashboard.qml"));
  component.create();
Whereas the project that was generated by Creator when I was testing your 
example is
  QGuiApplication app(argc, argv);
  QQmlApplicationEngine engine;
  engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
When I changed the test app to match my actual one, the incorrect behavior 
returned.

I know that I changed the code in main from a QGuiApplication to a 
QApplication when I started getting an assert when running
  ASSERT: "!"No style available without QApplication!"" in file 
kernel\qapplication.cpp, line 1060
I'm not sure what I'm doing wrong to incur that assertion? Unfortunately I
can't post my entire actual code here, as it has some intellectual property in 
it
but if you have any ideas on what I should look for I'm open to suggestions!

The only "style" things I see in my Qml is that my application is using the
CircularGaugeStyle 
(https://doc.qt.io/qt-5/qml-qtquick-controls-styles-circulargaugestyle.html)
which I do need to keep in my application.

Still digging...

Sean


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


[Interest] Qml MessageDialog not centered over window

2017-09-23 Thread Murphy, Sean
I'm not sure if this is a bug, or if I'm doing something wrong, but I'm trying 
to display a Qml dialog when an error occurs and it's coming up centered on my 
monitor, not centered over the application.

Relevant code:
Window {
MessageDialog {
id: errorDialog
objectName: "errorDialog"
title: "Error"
text: ""
}
Item {
id: functionItem
objectName: "item"

function receivedError(text) {
console.log("Error received: " + text);
errorDialog.text = "Error, " + text;
errorDialog.open();
}
}
}

Then on the C++ side I do 
QObject::connect(feed, SIGNAL(sigError(QVariant)),
cv, SLOT(receivedError (QVariant)));

The code works - whenever I emit sigError(errorString), the Qml function is 
called and the dialog opens with the correct message text. It's just that the 
position of the dialog is wrong.

This is occurring on Windows 7, Qt 5.9.1. I'm running on a dual monitor setup, 
and the dialog is showing up centered on the same monitor (left) that the 
application is running on, not centered across my entire desktop.

If this were a pure C++ application, I would say that the dialog isn't 
parented, but at least from this documentation, 
http://doc.qt.io/qt-5/qml-qtquick-dialogs-messagedialog.html, I think I'm 
parenting it correctly on the Qml side. The documentation states that " A 
MessageDialog window is automatically transient for its parent window. So 
whether you declare the dialog inside an Item or inside a Window, the dialog 
will appear centered over the window containing the item, or over the Window 
that you declared."

Sean
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] QtQuick Menu position on Android

2017-09-07 Thread Murphy, Sean
I'm extremely new to both QML development and Android development, so I may 
just be missing something obviously, but I'm struggling with a Menu's location, 
but only on the Android platform. I've got a settings button down in the lower 
right corner of my app. When clicked, it should popup() a Menu. On both the 
Windows and MacOS builds, whenever the button is clicked the menu pops up right 
near the button. But for some reason on Android, the menu pops up near the 
middle of the window. As shown in the code below, the menu is populated via a 
model from the C++ side, if that matters. 

I'm using Menu.popup(), which according to the documentation 
http://doc.qt.io/qt-5/qml-qtquick-controls-menu.html#popup-method, it 
supposedly " Opens this menu under the mouse cursor. It can block on some 
platforms, so test it accordingly." On Mac & Windows, that statement seems to 
hold true, but not on Android. Am I doing something wrong?

Relevant QML:

import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Extras 1.4
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.3
import QtQml 2.2

Window {
id: root
visible: true
width: 600
height: 1024
Menu {
id: settingsMenu

Instantiator {
model: sModel
MenuItem {
text: model.display
onTriggered: datafeed.slotSetSelectedPort(text)
}
onObjectAdded: {
settingsMenu.insertItem(index, object)
//console.log("QML: object added: " + object.text + ", index= " 
+ index);
}
onObjectRemoved: {
settingsMenu.removeItem(object)
//console.log("QML: object removed: " + object.text);
}
}
}

Button {
id: btSettings
width: 40
height: 40
style: ButtonStyle {
background: Rectangle {
implicitWidth: 40
implicitHeight: 40
border.width: control.activeFocus ? 2 : 1
border.color: "#88"
radius: 4
gradient: Gradient {
GradientStop {
position: 0
color: control.pressed ? "#040404" : "#080808"
}
GradientStop {
position: 1
color: control.pressed ? "#040404" : "#0a0a0a"
}
}
}
}
x: parent.width - 60
y: parent.height - 60
onClicked: settingsMenu.popup()
enabled: !datafeed.connected
opacity: enabled ? 1.0 : 0.3
iconSource: "qrc:/images/settings_white.png"
}
}
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Serial port / Bluetooth port to Android

2017-08-30 Thread Murphy, Sean
> > Is this just a difference of Android vs. Windows that our external BT device
> > doesn't show up as a serial device under Android like it does under
> Windows?
> 
> The Android way of working is the same for Bluez/Linux (although with
> rfcomm you can achieve the same), WinRT and the Apple platforms.

Ok.

 
> Your suggestion sound like a reasonable approach. However please be aware
> that although most of the QIODevice instances in Qt have a common
> interface there are slight differences anyway. One might not support
> buffered reads, the next may have a different spin on what's a proper line
> read etc. It's not the end of the world but you want to make sure to test your
> code with all the various QIODevice types.

I think I'm mostly safe there. The data is binary data in our own message 
format, 
so no line endings to deal with. And everything I'm doing on the reading side 
is 
handled in a slot that is connected to the ready read signal.

I'll start the rewrite and see how it goes!
Sean
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Serial port / Bluetooth port to Android

2017-08-29 Thread Murphy, Sean
> > On the Android device, we really only care about connected to the external
> > device via Bluetooth. But does this same behavior, where Bluetooth looks
> > like a serial device, exist under Android and I can still use QSerialPort? 
> > Or 
> > do I need some other device (i.e. QBluetoothSocket)?
> 
> You have to use QBluetoothSocket. There is no other choice. At the end of
> the day both interfaces are derived from QIODevice. "Merely" the path to
> your QIoDevice is different.

Thanks for the response.

Is this just a difference of Android vs. Windows that our external BT device 
doesn't show up as a serial device under Android like it does under Windows?

I don't think it will be a huge deal to rewrite, but 4 years ago when I started 
writing the affected class we were "only ever going to run this application on 
Windows using a USB to Serial adapter". So back then I created a class that 
inherits from QSerialPort and started coding. I think based on what you're 
saying 
about needing QBluetoothSocket under Android, and to make it more flexible in 
general, I should probably just change that class to inherit from QObject and 
take a 
QIODevice* so that I can swap out QSerialPort, QBluetoothSocket, or even 
QTcpSocket if needed?

Sean
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Dynamic QML menu from C++ data?

2017-08-28 Thread Murphy, Sean
Basically, I think I'm just missing the glue that gets me from the Qml 
delegate's text property and the QStandardItemModel::data(const QModelIndex &, 
int role) method 

Menu {
id: settingsMenu
Instantiator {
model: settingsModel
onObjectAdded: settingsMenu.insertItem(index, object)
onObjectRemoved: settingsMenu.removeItem(object)

delegate: MenuItem {
text: settingsModel.???  // <--- what goes here?
}
}
}

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


Re: [Interest] Dynamic QML menu from C++ data?

2017-08-28 Thread Murphy, Sean
> Example copied from a random project
> 
> https://gist.github.com/anonymous/2f803e7b49760b509d6a23c43901f52e

Thanks, can you show me what "modelData" is in your example, or how the .cpp 
side is laid out? I am using an Instantiator (and had been before I posted, 
based on something I stumbled across while searching for this), but I'm still 
missing some connection I need to make it work. 

Alternatively, this is my current code:
In main.cpp, I add three test items to the menu:
QQmlEngine engine;
QQmlComponent component(, QUrl("qrc:/qml/dashboard.qml"));
QObject* o = component.create();
settingsModel *model = o->findChild("model");
if (model)
{
qDebug() << "Adding items to model";
model->insertRow(0, new QStandardItem("one"));
model->insertRow(1, new QStandardItem("two"));
model->insertRow(2, new QStandardItem("three"));
} else {
qDebug() << "Invalid data model";
}

My settingsModel.cpp:
class settingsModel : public QStandardItemModel
{
Q_OBJECT
public:
explicit settingsModel(QObject *parent = 0);

private:
QStringList mPorts;
};

And then in my dashboard.qml:
SettingsModel {
id: settingsModel
objectName: "model"
}

Menu {
id: settingsMenu
Instantiator {
model: settingsModel
onObjectAdded: {
settingsMenu.insertItem(index, object)
console.log("QML: object added: " + object.text + ", index= " + 
index);
}
onObjectRemoved: {
settingsMenu.removeItem(object)
console.log("QML: object removed: " + object.text);
}

delegate: MenuItem {
text: "test"
}
}
}

When I used your example verbatim, I got the error:
qrc:///qml/dashboard.qml:93: ReferenceError: modelData is not defined
and I didn't get any menu items in the menu. When I run what I've attached, I 
do get a menu that has three entries, all labeled "test". Which makes sense 
based on what I have in there. So at least it seems like the calls to the 
model's insertRow() are triggering the Qml side to add items to the menu, but I 
just don't know what I'm supposed to change the text line below
delegate: MenuItem {
text: "test"
}
To get the menu to pick up the model item's string for that item?

Sean
 
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] Dynamic QML menu from C++ data?

2017-08-28 Thread Murphy, Sean
I'd think this is a pretty easy thing to do, but I'm struggling to find an 
example that shows it. In my QML, I have a button. When the button is clicked, 
a popup menu should open. That part I have working, what I'm struggling with is 
I need to be able to dynamically populate the popup menu from the C++ side, and 
then get which menu item was clicked on back to the C++ side. 

I'm struggling to find just a simple example of how to do this. Does anyone 
have a quick link to something like that?

Sean
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] Serial port / Bluetooth port to Android

2017-08-25 Thread Murphy, Sean
I have an application that currently works on Windows that we would like to 
port to Android. Under Windows, the application can communicate to an external 
device over either a USB to Serial converter or over Bluetooth. I can 
accomplish both of those connections using a class that inherits from 
QSerialPort to accomplish the communication. This works fine on Windows since 
both paths show up as COM ports, which QSerialPort plays nicely with: 
  - the USB to Serial device shows up as COM24
  - the Bluetooth device shows up as COM40
So just a simple call to QSerialPort::setPortName() allows me to switch between 
the usb serial connection and the Bluetooth connection.

On the Android device, we really only care about connected to the external 
device via Bluetooth. But does this same behavior, where Bluetooth looks like a 
serial device, exist under Android and I can still use QSerialPort? Or do I 
need some other device (i.e. QBluetoothSocket)?

Sean 

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


Re: [Interest] Set QTableWidgetItem checkbox when clicking anywhere on QTableWidget's row

2017-07-06 Thread Murphy, Sean
> > And then with the event filter approach, what would I actually be filtering
> on? 
  
> It's similar to the above, only it solves the same problem at a
> different location in your code. Instead of modifying a delegate, you'd
> intercept the mouse click and, again, handle the state change yourself.
> Indeed the widgetApp isn't going to tell you if you're over the checkbox
> in the item view as the checkbox there is not a widget but rendered by
> the delegate directly, but you don't need that info either. All you need
> to know if the mouse is over a row, and which row. QAbstractItemView can
> tell you that just fine...
> 
> In both cases, you simply handle the mouse event yourself, and use
> setData yourself to toggle the state of the checkbox when there is a
> click *somewhere* on the row. That's what you were after, right?

That is what I was after, yes. Just to be clear, in the event filter method, 
the 
event filter would intercept the click before it gets to the checkbox correct? 
And then I would be able to explicitly set the checkbox's state in my handler 
and avoid the double-toggle that I was experiencing previously? 

Sorry, I'm too lazy to try it this second, but I think I get where you're going!

> 
> >> P.S. Oh, and get rid of the QTableWidget. Use QTableView instead.
> > What does that do for me in this case?
> Nothing to solve this particular issue. Its just a pet-peeve of mine.
> > My table is very simple, it's basically a read-only table EXCEPT for 
> > allowing
> the user to check/uncheck items. Maybe I'm wrong in my ideas, but I tend to
> view QTableWidget as working pretty nicely for very simple tables like this
> but with it you get less control than QTableView. I feel like when I've used
> QTableView for situations like this that it takes more code just to get up and
> running when compared to creating the QTableWidget. I'm totally willing to
> change my views on QTableView vs. QTableWidget if you think I'm wrong!
> If you must use an item based API, I'd take QStandardItemModel (very
> wrong name, but ok...) with a standard item view. It provides a much
> better decoupling of the UI aspects and the data aspects of the
> application. No need to modify your UI code if you decide your data
> should come from a different data source in the future, and no need to
> change your data setup if you decide you want a dropdown instead of
> table... Also, it makes it easier to introduce things like
> QSortFilterProxyModel into the stack later on.

Yeah, I get why the view/model approach is far more flexible if things need to 
change down the road. But in this case, I'm like 95% sure we won't change 
how we're presenting this data. It's not like my manager is going to change
his mind a week from now, right? ;)

Thanks for the help, I'll give your suggestions a try shortly
Sean

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


Re: [Interest] Set QTableWidgetItem checkbox when clicking anywhere on QTableWidget's row

2017-07-06 Thread Murphy, Sean
Thanks for the response Andre

> I'd probably handle this via either a custom delegate or by using an
> event filter.

Can you go into a little more detail on these two approaches? 

As far as the custom delegate approach, I'm assuming that if I follow the Spin 
Box Delegate Example 
(http://doc.qt.io/qt-5/qtwidgets-itemviews-spinboxdelegate-example.html) and 
just replace the spin box with a checkbox that would get me there?

And then with the event filter approach, what would I actually be filtering on? 
I'm assuming you're suggesting to filter all clicks on the QTableWidget and 
then trying to detect if it's over a checkbox via cursor position, and then 
handle the click different based on that? My main sticking point with that is 
that a checkable QTableWidgetItem doesn't seem to be an actual QWidget, so I'm 
something like qApp->widgetAt(QCursor::pos()) isn't going to tell me whether 
I'm over the checkbox, it's going to tell me I'm over the QTableWidget, right? 
So I'm not seeing how I tell whether the mouse was over the check box's pixels 
or not. Let me know if you meant something else for this approach.

> 
> P.S. Oh, and get rid of the QTableWidget. Use QTableView instead.

What does that do for me in this case? My table is very simple, it's basically 
a read-only table EXCEPT for allowing the user to check/uncheck items. Maybe 
I'm wrong in my ideas, but I tend to view QTableWidget as working pretty nicely 
for very simple tables like this but with it you get less control than 
QTableView. I feel like when I've used QTableView for situations like this that 
it takes more code just to get up and running when compared to creating the 
QTableWidget. I'm totally willing to change my views on QTableView vs. 
QTableWidget if you think I'm wrong!

Sean
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


  1   2   >