Re: [Interest] Should Q_INVOKABLE functions be marked as such in the documentation ?

2017-02-22 Thread Bo Thorsen

Den 22-02-2017 kl. 11:13 skrev Pierre-Yves Siret:

Hello,

Reading the doc, there is no indication that a function is Q_INVOKABLE.
It can sometimes be useful to know what functions of a Qt C++ class (not
specifically designed for QML) can be called from QML in addition to the
slots.

The only way I know to do that is to read the source of the class
(thanks to the Woboq people for easing that pain).

Is there a reason to hide this information ?


My guess is that it's only this way because no one asked for it before. 
Sounds like a reasonable thing to show.


I checked the bug tracker, but I didn't find this. You should add a 
feature request.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QThreadPool - global instance or custom one

2017-01-20 Thread Bo Thorsen
I have exactly the same rule for my coding as Thiago does. And my answer
would be the same for this. If one of the models have jobs that could hurt
the performance of the other jobs, give it a pool of it's own. If not, you
can share.

Bo.

2017-01-20 4:44 GMT+01:00 Frank Rueter | OHUfx :

> Great, thanks for the quick reply and confirmation.
> One more question: Would you create one QThreadPool instance for the
> entire application or create new instances as you go (from within different
> modules). Does it matter?
>
> Cheers,
> frank
>
> On 20/01/17 3:29 PM, Thiago Macieira wrote:
>
>> On sexta-feira, 20 de janeiro de 2017 11:59:31 PST Frank Rueter | OHUfx
>> wrote:
>>
>>> Hi all,
>>>
>>> I have started using QThreadPool for the first time and am wondering if
>>> it's save/recommended to create my own instance of it or to always use
>>> the global instance?
>>>
>> The rule I use is that you should use your own pool if you plan on
>> launching
>> tasks that may block, but it's ok to use the global one if you need to run
>> things that run as fast as they can without blocking.
>>
>> QHostInfo uses its own thread pool because it calls a blocking function
>> that
>> is known to sometimes take 30 seconds to return (getaddrinfo).
>>
>> In my case my app will run inside a host application, so my gut feeling
>>> says to create my own thread pool so I don't accidentally hijack the
>>> host application's pool, but I may be wrong?!
>>>
>> You're probably right. QHostInfo's example also matches your thinking:
>> Qt's
>> behind-the-scenes usage should not affect the main application's ability
>> to
>> use the global thread pool.
>>
>>
> ___
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Is it possible to use QtQuick Item instead of Graphics View Framework ?

2016-12-09 Thread Bo Thorsen

Den 09-12-2016 kl. 08:59 skrev jack ma:

Hi,
Is there any way to draw *interactive* complex shapes(lines,arc,..) with
QtQuick item like QGraphicsItem?
seems that Canvas item can draw shapes but can't interact?


The way to do this is to create your own items and respond to the mouse 
events on them. In that respect, the QtQuick items will be a similar to 
the QGraphicsItem.


I hope this helps,

Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QMenu size

2016-11-17 Thread Bo Thorsen

Hi Joshua,

Den 15-11-2016 kl. 17:28 skrev Joshua Grauman:

Thanks! These are great ideas. It's not about making it work like
another system, but it is a unique requirement having to do with
recording the screen...


Typical, you actually managed to find a good reason for doing this :)


If you don't mind, could you clarify a bit what you mean with a couple
of your suggestions?


- Work with the width for height tricks


What does this mean?


You could use the heightForWidth() to have some control over the size of 
it. Wouldn't be my first choice here and I'm not even sure where I would 
take it. But I mentioned it because you said you had to control the size 
of it, and this is one of the lesser known tricks that I sometimes use 
to do it.



- You can move the menu after it appears with either a
reimplementation in the resizeEvent, eventFilter on resize or other
events, or using 0 time single shot timer


I understand the first two of these, but where would I implement a 0
time single shot?


The timer is in the class that opens the popup menu. If you have a 
method where you set up the menu, you can do something like this:


QMenu popup;
// set up the menu here
QTimer::singleShot(0, [=]() {
  // Handle popup size here
}
popup.exec();

Bo.


On Tue, 15 Nov 2016, Bo Thorsen wrote:


Den 08-11-2016 kl. 23:05 skrev Joshua Grauman:

 Hello all,

 I am wondering if there is a way to customize the size of a QMenu used
 as a context menu. I have it so that when I right click, a popup menu
 comes up. But I would like it so the QMenu doesn't ever go outside of
 the window it is clicked in. Right now, if you click near the bottom,
 the QMenu drops below my app. Or if I have a QMenu with a lot of items,
 it breaks it up into two columns worth of items, is there a way to make
 that more (for a wider and less tall sub-QMenu)? Thanks for any
thoughts.


This sounds to me like you are trying to force Qt to do something that
some other system used to do?

I have a lot of requests from customers and I always try to make them
accept that the default way of doing things are there for a number of
reasons and they should accept it the it is. So, my advice is to stop
thinking about this. Or make the guy deciding this stop thinking about
it :)

However, if you can't do that, you always have options. Here are a set
of some of the things I would try:

- Set the maximum height on the QMenu

- Work with the width for height tricks

- You can move the menu after it appears with either a
reimplementation in the resizeEvent, eventFilter on resize or other
events, or using 0 time single shot timer

- There are probably a bunch of possible hacks that might work in the
area of proxy QStyle subclasses

I hope this helps.

Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest





Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QMenu size

2016-11-15 Thread Bo Thorsen

Den 08-11-2016 kl. 23:05 skrev Joshua Grauman:

Hello all,

I am wondering if there is a way to customize the size of a QMenu used
as a context menu. I have it so that when I right click, a popup menu
comes up. But I would like it so the QMenu doesn't ever go outside of
the window it is clicked in. Right now, if you click near the bottom,
the QMenu drops below my app. Or if I have a QMenu with a lot of items,
it breaks it up into two columns worth of items, is there a way to make
that more (for a wider and less tall sub-QMenu)? Thanks for any thoughts.


This sounds to me like you are trying to force Qt to do something that 
some other system used to do?


I have a lot of requests from customers and I always try to make them 
accept that the default way of doing things are there for a number of 
reasons and they should accept it the it is. So, my advice is to stop 
thinking about this. Or make the guy deciding this stop thinking about it :)


However, if you can't do that, you always have options. Here are a set 
of some of the things I would try:


- Set the maximum height on the QMenu

- Work with the width for height tricks

- You can move the menu after it appears with either a reimplementation 
in the resizeEvent, eventFilter on resize or other events, or using 0 
time single shot timer


- There are probably a bunch of possible hacks that might work in the 
area of proxy QStyle subclasses


I hope this helps.

Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] What don't you like about Qt?

2016-09-22 Thread Bo Thorsen

Den 21-09-2016 kl. 23:53 skrev André Pönitz:

On Wed, Sep 21, 2016 at 05:42:44AM +, Shawn Rutledge wrote:


On Sep 20, 2016, at 22:52, Rob Allan <rob_al...@trimble.com> wrote:

My biggest gripe is that the Qt Quick object model seems to be much
more poorly supported in C++ than it is in QML. For example, in C++
you really only have access to QQuickItem - none of its derived
classes are documented, and their interfaces are private - so the
only way to manipulate items is using a generic "setProperty"
syntax. This is in stark contrast to QML where all the QML types,
methods and properties are available to you. When you have an app
that builds most of its UI dynamically from C++ code (as ours
does), this makes life pretty difficult. I guess this is one area
where widgets would score better than Qt Quick (but we still prefer
Qt Quick for a number of reasons).


It’s intentional though: we don’t have to worry about binary
compatibility that way, or even source compatibility to an extent -
it’s only the QML API that we have to keep compatible.


I believe quite a few of the people asking for C++ access to Qt Quick
are perfectly aware of the state of the current implementation, at
least to a degree to understand the desire to not set access to it in
stone. But, after weighing pros and cons, they came to the conclusion
that having *any* "official" access, even one that does not come with
any binary or even source compatibility guarantees is more valuable
than being restricted to QML.

It is beyond me how one can hide behind the "we can't/do not want to
guarantee compatibility" argument when people explicitly declared *for
years* that they don't care about such for that particular scenario.


We don’t strictly even need PIMPLs (and I wonder if we could get any
speedup or memory savings if we didn’t have them), but most of the
classes have them anyway.  I guess maybe the original authors were
anticipating that the C++ API might become public some day, so they
have private objects just in case.  But making more of them public is
the same as locking the API and reducing flexibility.

If there are any API warts, they become difficult to fix after that.
(E.g. the restriction that we can neither add nor remove virtual
functions is downright crippling sometimes.)


There is no API lock if there is no compatibility promise. People ask
for the API, not the promise. Making it accessible with the usual _p.h
No guarantees/"We mean it." would not restrict any development,
and make a few people happier.


André, while I actually agree with pretty much everything you write, I 
also think you're a bit naïve in thinking it would work. I can already 
imagine all the angry emails about how difficult it is to upgrade to new 
versions because people have to rewrite the C++ code behind the QML 
stuff. This would lead to a lot of "Qt sucks" zealots in companies out 
there. Especially from those who have been forced by others to use a 
framework they weren't interested in in the first place. Introducing 
anything that will intentionally break source compatibility between 
releases is IMHO a complete no-go.


What I would like to see that mostly fixes this would be:

- a factory class so you actually can instantiate QML objects from C++ 
without eval'ing strings


- a way for the property setting and getting to fail, if the property 
isn't declared. Dynamic property setting always works at the moment


- a C++ and JS way to set up bindings

Yes, the code looks different than normal instantiate and call methods 
on C++ objects. But it's a way to do support C++ code behind QML without 
binary compatibility issues.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ experts for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] What don't you like about Qt?

2016-09-19 Thread Bo Thorsen

Okay, I'll bite:

* Poor standard of some modules - Qt Multimedia and Qt Components especially
* Too much focus on features instead of fixing bugs
* Designer plugin development/deployment sucks (should be in a scripting 
language or json, and should be possible to do per project)

* Current gerrit workflow make Qt contributions a pain to get started with
* Javascript chosen as the scripting language for Qt (see this for 
giggles: https://www.destroyallsoftware.com/talks/wat)

* Commercial pricing is impossible to figure out for my customers
* Not using exceptions (I know, won't happen, and most appreciate this)

Compared to the awesome quality and completeness of Qt, those are minor 
points. I've been a happy Qt coder for almost 20 years now and hope for 
20 more :)


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Memory Leak when instantiating QWidget based windows

2016-09-10 Thread Bo Thorsen

Den 08-09-2016 kl. 12:55 skrev Konstantin Shegunov:


On Wed, Sep 7, 2016 at 11:23 PM, Mike Jackson <imikejack...@gmail.com
<mailto:imikejack...@gmail.com>> wrote:

We monitor the memory use before and after the loop using OS X's
Activity monitor. At the end of the loop there is more memory being
used than before the loop, by about 2~3MB worth.

This isn't reliable. Consider the following C++ only code:

int main(intargc,char**argv)
{
  struct X;
  X * x = nullptr;

  struct X {
int data[1024];
  };

  for(qint32i=0;i<10;i++){
x = new X[1024];
delete x;
  }

  return 0;
}

In the KSysGuard (KDE's system monitor) I observe for the memory
consumption: 12 908k, 23 048k shared before the loop and 12 944k, 25
112k shared after the loop. There isn't a leak here, yet there's a
difference. The OS's heap manager may free the memory immediately, may
cache it, or hold on to it. Ultimately it's out of your control, that's
why you should use a code analyzer (like valgrind to track leaks).


You need to use "delete[] x;" or you can't say that you don't have a 
memory leak.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Native event filter in QtService

2016-06-24 Thread Bo Thorsen

Hi all,

I'm copying this to devel, because it fits in a discussion a week or two 
ago.


Den 24-06-2016 kl. 10:56 skrev Tony Rietwyk:

qtservice_win.cpp around line 830 at your reference [1] installs its own
nativeEventFilter - probably displacing yours.

I suspect you'll need to merge the Qt filter into yours, and get rid of
that install.


That is impossible for commercial projects because the solutions are 
LGPL only. You can't copy LGPL code into your own code base unless you 
are using GPL or LGPL yourself.


And that's why I copied this message to devel, because there was a 
discussion on whether to add solutions to Qt Core or not. And one of the 
arguments against is that people can just use the solutions as they are. 
This is one case, where apparently that's not (at least currently) possible.


I can come up with a couple of workarounds for this, sure. But these are 
all brittle and may not work if the solutions code is changed.



*From:*Interest
[mailto:interest-bounces+tony=rightsoft.com...@qt-project.org] *On
Behalf Of *Julius Bullinger
*Sent:* Friday, 24 June 2016 5:25 PM
*To:* interest@qt-project.org Interest
*Subject:* [Interest] Native event filter in QtService

I’m trying to write a small (windows only) service based on QtService
[1] listening for some USB device events. For this, I created a
NativeDeviceEventFilterclass based on QAbstractNativeEventFilter. It
works perfectly when used in a QCoreApplication.

Now, when installing this event filter in my UpdaterServiceclass, it
isn’t being called.

I tried each of:

  application()->installNativeEventFilter(deviceEvent_);

  QCoreApplication::instance()->installNativeEventFilter(deviceEvent_);

QAbstractEventDispatcher::instance()->installNativeEventFilter(deviceEvent_);

both in the service’s constructor and start()method, as well as using a
local instance of NativeDeviceEventFilter,

but none of these worked. The event just isn’t registered at all.

Has anyone ever done something like this? Or is there another way to
receive native messages (MSG structs) in a QtService?


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] 5.8 Features?

2016-06-22 Thread Bo Thorsen

Den 21-06-2016 kl. 22:55 skrev Jason H:

I feel like the last few releases have been run by the trolls, and not the 
users of Qt. I was hoping open governance would enable the community to direct 
Qt development, but I seem to have misinterpreted what it means. I'm looking 
for what's going into 5.8.. not much listed on the releases page.

I'd like to suggest that mobile get some much needed love.
- Application state transitions; Foreground, background
- Background processing API
- Screen wake lock API
- In-app Notifications: local, remote

While I have those characterized as "mobile" there are things like 
notifications occurring on desktop platforms.

Any thoughts?


There's only one reason why you don't see more features for the mobile 
parts: There are not enough developers on it. And that's not because 
QtCompany is doing anything wrong, they just have their priorities 
different from what you have.


Personally I don't care about mobile at all. I haven't had a mobile 
customer since 2011 and I don't see that changing. My focus is almost 
entirely on Linux embedded and Windows desktop. Those are the areas 
where a lot of applications are written.


I'd love to see the mobile platforms thrive. But unless you Qt users 
start becoming Qt developers and contribute to it, I don't see that 
happening.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Migrating QWeakPointer to Qt5

2016-05-06 Thread Bo Thorsen

Den 06-05-2016 kl. 07:35 skrev Tom Isaacson:

I'm moving some Qt4.8.2 code which uses QWeakPointer to Qt5.6.  Simplifying a 
lot it looks like this:

class MySettings : public QObject
{
Q_OBJECT
}

class MyClass : public QObject
{
Q_OBJECT

private:
QWeakPointer m_xSettings;
}

MyClass::MyClass(MySettings* pSettings, QObject* pParent)
: QObject(pParent)
, m_xSettings(pSettings)
{
}

but when I compile under Visual Studio 2013 I get this error:
error C2664: 'QWeakPointer::QWeakPointer(const QSharedPointer &)' : cannot 
convert argument 1 from 'MySettings *' to 'const QWeakPointer &'

I tried changing the QWeakPointer to a QPointer but now I'm getting:
error C2440: 'static_cast' : cannot convert from 'QObject *' to MyClass *' 
(GeneratedFiles\Debug\moc_MyCode.cpp)

Is there a recommended method for migrating the use of QWeakPointer into Qt5?


With this code, you need QPointer.

Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] What's the recommended way to put QObjects in smart pointers?

2016-05-05 Thread Bo Thorsen

Den 04-05-2016 kl. 16:48 skrev Nikos Chantziaras:

I've been removing every trance of 'new' and 'delete' from my code and
switching to something like:

  auto obj = std::make_unique(ctor args);

(Or std::make_shared, depending on the situation.)

But for QObjects with a parent, that can go horribly wrong. So I have to
do annoying stuff like:

  auto dialog = new QDialog(parent);
  // work...
  delete dialog;

Yes, 'parent' will eventually delete 'dialog', but that doesn't help
much when 'parent' is a long lived object (like the main application
window.)

Is there a Qt-specific idiom where I can manage QObjects that have a
parent with a smart pointer and not have to worry about double-deletion?

Or, to phrase it in another way, is there a way to eliminate the 'new'
keyword completely from my code-base when using QObjects with a parent?


I'm still not sure if I should respond to this or not. You're clearly 
trying to solve an unsolvable problem.


This mail is going to sound like a rant, because I've heard those types 
of arguments from Qt newbies again and again. But it's actually not. 
There's information here that will lead you to a code style that fits 
the Qt memory model. Not your memory model.


First, you need to listen to this and fully understand it: There is *no* 
way you can code C++ so memory errors are impossible.


Using smart pointers is just a silly pipe dream of the nineties that 
unfortunately hasn't gone away. As Herb Sutter (I think, not completely 
sure) once said: "Smart pointers is a solution in search of a problem".


Smart pointers is good for one thing only: To delete objects that 
control their own life span.


For all other - and that's 99.9% - objects, it's cleaner simpler and 
more efficient if you get rid of the notion that a system can do it for 
you, and start giving clear lifetime ownership of your objects.


Yes, you can get crashes or memory loss. That's why you don't hire crap 
coders to do C++, and check your code with tools like valgrind.


I'm sure you will have a long list of objections as to why I'm 
completely wrong. Shared pointer lovers usually do. I don't care. I've 
been doing Qt coding for 20 years and have tried every trick available 
and come to the conclusion that it's actually only up to me writing good 
code.


I hope this helps. I give the same type of arguments to my customers. 
The smart ones get it, the others pay with increased maintenance cost 
over the years.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Probable Qt bug in widgets display

2016-04-20 Thread Bo Thorsen

Den 20-04-2016 kl. 10:56 skrev Etienne Sandré-Chardonnal:

Here are two screenshots:

Normal display : http://www.eclat-digital.com/downloads/qtbug-normal.png
Bugged display : http://www.eclat-digital.com/downloads/qtbug-issue.png


This looks like a paint bug to me. The best way forward for you is to 
create a small self contained application that shows the problem. In 
this case, it should probably be possible to do it in 10 lines of code 
or so. And then add a description on how to reproduce it. Create a bug 
report with those two things.


The good thing about the small test case is that you also make it very 
clear if it really is a Qt bug or if you did something on your side that 
triggers it.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] [Qt3D] Render to video

2016-04-18 Thread Bo Thorsen

Den 18-04-2016 kl. 05:46 skrev Andy:

Goal: generate video with a user-specified resolution, frame rate, &
container/codec format from an animation in my Qt3D window

(Disclaimer: I've never worked with video files before!)

As far as I can tell, Qt doesn't provide a way to generate video files
directly, so I think I have to write a series of QImages to disk and use
them to generate a video using ffmpeg.  This seems like it will take a
large amount of disk space, be pretty heavy on the I/O, and generally be
slow.  Are there better solutions?

If I need to do it that way though, I must generate QImages from my
existing Qt3DCore::QAspectEngine in my QWindow-derived class.  I don't
see a clear/elegant way to do this.

I think I need to create an offscreen surface? window? with the correct
resolution and then somehow render & animate my scene to it, saving
snapshots as I move the camera.  (I am already using QAbstractAnimation
to move the camera, so I would use it to grab the snapshots as well.)
Can I use the same root entity in multiple QAspectEngines? (i.e.
setRootEntity() to my root entity in the new offscreen and tell it to
render.)

Has anyone done this before?  Is this even close to the right approach?

(I'm using straight C++ - no QML.)


Why do you want to do this in Qt when you can do it with applications 
like Camtasia?


If you do want to follow this, the first part is to just generate 
screenshots. There's an example app in Qt that does this: 
http://doc.qt.io/qt-5/qtwidgets-desktop-screenshot-example.html.


Second, find one of the libraries that does video encoding and use your 
screenshots there.


Shouldn't be too hard, but you might have to convert the pixels manually 
to the video library format, so it could be quite slow.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Upcoming mobile Qt features?

2016-03-15 Thread Bo Thorsen

Den 14-03-2016 kl. 20:26 skrev Jason H:

I'm being asked for more modern features, I don't know where these are on the 
Qt roadmap?

- TouchID/FingerprintManager:
   Now that both mobile platforms have platform-level APIs for fingerprints, is 
Qt going to support them in some way?

- Streaming video:
   Capture, send, receive "live" video to enable real-time video chat, yes, 
like skype/google hangouts/facetime.

Meanwhile, I'm still looking for Qt to abstract these mobile old-but-goodies:
- Push notifications
- Background operations
- Screen wake-locking
(I have a platform shim for those, but would just prefer to use a standard 
x-platform interface)

Anyone know the 5.7/5.8 roadmap? The only mobile thing listed on the wiki is:
- Android: Qt can now be used to easily create Android Services*

* This seems to be an either-or. Not an app with services?


Jason, to me it looks like Qt on mobile is improving very slow. There's 
definitely a need for more contributors in this area. I'm not saying 
that you can't send this list, but it is an open source project after 
all. The people on this list who want to use Qt on mobile should 
consider getting together and try to start improving Qt itself.


I'm aware, of course, that this isn't always possible. I currently have 
no time to do the Qt improvements I'd like to. So I understand if you 
don't have time yourself. But I think it's clear from the roadmap that 
the community will have to step up in this area.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Antwort: Re: QML Loader Performance

2016-03-09 Thread Bo Thorsen

Den 09-03-2016 kl. 08:30 skrev Ingo Schiller:

Hi Bo, Hi everyone

thanks for your reply and the thoughts you have spent on my problem.

You are right, using these cascading loader elements is a fundamental
structure of the program which will not be easy to change. The point is
that everything is user editable. The user can decide which blocks
should be displayed and which widgets (there is the bad word again ;-) )
  are displayed. Almost everything is editable, positions, sizes,
parameters... And widgets are attached to theses blocks and relative to
them ,meaning they can be dragged around with them and change size with
them, etc.. Thats also the reason why I can not just use ony hierarchy
of loaders, that would not allow to change the content of the blocks.


Which is also why I'm advocating the model based approach because that 
one attacks the problem from a completely different angle and will most 
likely solve your issues.



I don't think I understood your proposed approach:

"Another option would be to attempt this with C++ instead of doing
loaders. I mean instantiating every item inside in C++ code instead of
doing it in QML/JS code. This makes the code a lot less friendly to
modify, but it seems you are desperate enough to start pulling out
solutions that hurts in other ways just to get more speed."

How can I generate visual QML elements in C++? These are mostly elements
drawn in QML so how could I achieve this? (Some of them are drawn in c++
and exportet to QML)


QQmlComponent component(yourView.engine(),
  QUrl::fromLocalFile("MyItem.qml"));

for (...)
  QObject *object = component.create();

Now set the parent to the parent in the qml view (which you can get with 
a Q_INVOKABLE method.


This is basically what a loader does. But with a loader, you create the 
component every time. Here you can reuse the component to create all the 
widgets.



Your last point, to do a redesign on models instead, could be possible I
think, although it would require a lot of changes to give it a try. I
could make everything a widget and establish the hierarchy in some other
way so that widgets can still be relative to blocks in terms of
position. Although I also tried only having one block on a page and
putting  all widgets in there which did not improve loading speed.


Yes, it will be a lot of work, and the dynamic creation would be less to 
try first. But this is the real solution to your problem and speedwise 
it will be many times faster than the loaders.


Bo.


Von: Bo Thorsen <b...@vikingsoft.eu>
An: interest@qt-project.org,
Datum: 08.03.2016 15:37
Betreff: Re: [Interest] QML Loader Performance
Gesendet von: "Interest"
<interest-bounces+ingo_schiller=raykiel@qt-project.org>




Hi Ingo,

Den 07-03-2016 kl. 08:27 skrev Ingo Schiller:
 > I have a serious performance problem in my application which uses QML
 > for the UI and several C++ datamodels. The application consists of
 > several "pages", which is a set of ui elements and covers the whole
 > screen. These pages can be loaded on request. Loading such a page is
 > done by a QML Loader component. The loaded page itself loads other
 > elements, so called "blocks" which group several ui elements. These
 > "blocks" also contain a loader element which loads so called "widgets",
 > UI qml elements used to display information. After loading a block or
 > widget JS functions are used to set the properties (15 - 30) of the ui
 > elements such as position, z-layer, data to display, etc.
 >
 > Load Page -> load block 1 -> load widget 1
 > -> load widget 2
 > -> load widget 3
 >...
 > -> load widget n
 > -> load block 2 -> load widget 1
 > -> load widget 2
 > -> load widget 3
 >...
 > -> load widget n
 >...
 > -> load block n  -> load widget x
 >
 > The problem is, that loading sich a "page" is far too slow, On a really
 > good developer PC and as a release build it takes 150ms. On a weaker
 > hardware it takes several seconds which is not acceptable. The time
 > required to load a "page" is linear with the amount of "widgets" on that
 > "page", no matter what widgets are on that page. I have very simple
 > widgets which have only a label to display, up to grafical widgets with
 > transparency and animations, but that does not seam to influence the
 > loading procedure.
 >
 > I already tried several things  to speed it up:
 > - Use qt quick compiler
 > - Strip down loaded elements to have fewer properties
 > - Construct all elements on startup and only set them (in-)visible on
 > request
 > - Omit z-layering
 >
 >

Re: [Interest] QML Loader Performance

2016-03-08 Thread Bo Thorsen

Hi Ingo,

Den 07-03-2016 kl. 08:27 skrev Ingo Schiller:

I have a serious performance problem in my application which uses QML
for the UI and several C++ datamodels. The application consists of
several "pages", which is a set of ui elements and covers the whole
screen. These pages can be loaded on request. Loading such a page is
done by a QML Loader component. The loaded page itself loads other
elements, so called "blocks" which group several ui elements. These
"blocks" also contain a loader element which loads so called "widgets",
UI qml elements used to display information. After loading a block or
widget JS functions are used to set the properties (15 - 30) of the ui
elements such as position, z-layer, data to display, etc.

Load Page -> load block 1 -> load widget 1
-> load widget 2
-> load widget 3
   ...
-> load widget n
-> load block 2 -> load widget 1
-> load widget 2
-> load widget 3
   ...
-> load widget n
   ...
-> load block n  -> load widget x

The problem is, that loading sich a "page" is far too slow, On a really
good developer PC and as a release build it takes 150ms. On a weaker
hardware it takes several seconds which is not acceptable. The time
required to load a "page" is linear with the amount of "widgets" on that
"page", no matter what widgets are on that page. I have very simple
widgets which have only a label to display, up to grafical widgets with
transparency and animations, but that does not seam to influence the
loading procedure.

I already tried several things  to speed it up:
- Use qt quick compiler
- Strip down loaded elements to have fewer properties
- Construct all elements on startup and only set them (in-)visible on
request
- Omit z-layering

Profiling the loading procedure shows that compiling the qml elements
and painting are not the issues.

Can anyone advise what I could do else? Or is that loader component so
terribly slow? Any help is highly appreciated!


What you're doing here seems really difficult to speed up. I guess the 
problem is the multiple layers of loaders you have.


But I guess that's a pretty fundamental design for you application, and 
not one you're about to change.


If you could create a set of pages based on the blocks that can go in 
them, you could have a single loader object instead of the n * m + 1 
loaders you're doing right now.


Another option would be to attempt this with C++ instead of doing 
loaders. I mean instantiating every item inside in C++ code instead of 
doing it in QML/JS code. This makes the code a lot less friendly to 
modify, but it seems you are desperate enough to start pulling out 
solutions that hurts in other ways just to get more speed.


If you can cut down on the initialization for each page, block or 
widget, that would obviously help a lot. You mention that JS code is run 
after each add, which sounds like a place where you might have some 
possibilities.


Fewer bindings might also be a possibility.

Have you considered a total redesign based on models instead? It sounds 
like a page is really just a list of widgets - which is a bad word in 
QML land :) - so perhaps you would be much better off with a standard 
list model, a list view where what you have as a widget now is a 
delegate for a row in the model. That would definitely be much much 
faster than what you're doing right now.


Those are just the ideas I have off the top of my head. I hope it helps.

Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Emitting signal from QThread::run()

2016-02-29 Thread Bo Thorsen

Den 27-02-2016 kl. 07:15 skrev Syam:


Hello,

Inspired from the recent discussions on QThread, I have the following
question.
I have:

class MyThread : public QThread
{
Q_OBJECT
 //the constructor and other stuff

signals:
  void mySignal();

protected:
   virtual void run()
   {
  while(true)
  {
 //do something
 if(some_condition) emit mySignal();
  }
   }
};


void MainWindow::someFunction()
{
MyThread *thread = new MyThread;
connect(thread, SIGNAL(mySignal()), this, SLOT(myGuiSlot()),
Qt::QueuedConnection);
thread->start();
}


//

Will the above code work fine? In myGuiSlot() I am typically
manipulating some widgets - setting the text of a QLabel etc.


Don't ever do this. I don't subscribe to the idea that you should never 
subclass QThread yourself, but I think it's a very bad idea to subclass 
and use signals and slots.


The reason is the discussion that followed in this thread - it's so hard 
to understand precisely what happens with the connected signals and slots.


I usually tell people that QThread is a bridge between the creating and 
the created thread. It's not actually, but conceptually it helps them to 
realize that they should not assume they can understand the qobject 
thread affinity inside the object itself.


If you use signals and slots in a thread object, you do this:

QThread* thread = new QThread;
MyObject* object = new MyObject;
object->moveToThread(thread);
thread->start();

If you don't and only do calculation, or use a queue or something to 
handle the communication with hardware, etc, then you can subclass 
QThread and do stuff in run(). (This part is where I disagree with the 
"you're doing it wrong" crowd.) This is safe because without signals and 
slots in there you don't use the thread affinity and you don't have a 
local event loop.


Guys, this is only hard if you insist on doing something that 
experienced people say you should stay away from. The OP thought the 
MyObject should create it's own thread. No, that's wrong. Accept it and 
move on. Or create a wrapper object around it if you must encapsulate it.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Add margin spacing between QComboBox item icon and text ?

2016-01-20 Thread Bo Thorsen

Den 20-01-2016 kl. 15:23 skrev Edward Sutton:

I don't know what you did, but that's not how it normally looks. Obviously not.


You are correct. My mistake.

I could not reproduce when I made a new app using both SVG and PNG image 
sources.

The root cause was my icon sizes were too big for the QComboBox::iconSize.  I 
had also found some stylesheet commands I had added to the QComboBox.

I do not remember why I added a styleSheet.  Perhaps to make it more fat-finger 
touch-friendly for Android or iOS.  Anyway, I must re-think and re-test.


I always tell my customers to stay away from style sheets. They are way 
more trouble than what they are worth.


I'd love to see this crap removed from Qt in Qt 6 completely. But that 
won't happen.



Thank you for taking time to reply.


np :)


On Jan 19, 2016, at 12:43 AM, Bo Thorsen <b...@vikingsoft.eu> wrote:

Den 18-01-2016 kl. 19:36 skrev Edward Sutton:

When the QComboBox drop-down is activated, the icons overlay the text
making it hard to read.

Is there a property or style sheet to adjust this?

For the currently selected its, the icon and text have good spacing
QComboBox.

Item icon overlays text.


I don't know what you did, but that's not how it normally looks. Obviously not.

Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.vikingsoft.eu=CwICAg=G4BpsyPyB19LB50bn2swXw=cAG2c-SQES5P2qb8IW-uwnBOCX_f2qYJIlzenFnoHUc=72lOuNx0ynlsEHuFrPABPSERn-3rl6lLcmGJPjwMUyM=_eiFP6KwO-a23ewP0pR6PmtKfHuItsnBxI5CqbqHf0A=
 ___
Interest mailing list
Interest@qt-project.org
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.qt-2Dproject.org_mailman_listinfo_interest=CwICAg=G4BpsyPyB19LB50bn2swXw=cAG2c-SQES5P2qb8IW-uwnBOCX_f2qYJIlzenFnoHUc=72lOuNx0ynlsEHuFrPABPSERn-3rl6lLcmGJPjwMUyM=hTREm7d0dsQDlkh2BmNas5Hp0G__e31BEBQpjIDdAAw=


This email and any files transmitted with it from The Charles Machine Works, 
Inc. are confidential and intended solely for the use of the individual or 
entity to which they are addressed. If you have received this email in error 
please notify the sender. Our company accepts no liability for the contents of 
this email, or for the consequences of any actions taken on the basis of the 
information provided, unless that information is subsequently confirmed in 
writing. Please note that any views or opinions presented in this email are 
solely those of the author and do not necessarily represent those of the 
company. Finally, the recipient should check this email and any attachments for 
the presence of viruses. The company accepts no liability for any damage caused 
by any virus transmitted by this email.



Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Add margin spacing between QComboBox item icon and text ?

2016-01-18 Thread Bo Thorsen

Den 18-01-2016 kl. 19:36 skrev Edward Sutton:

When the QComboBox drop-down is activated, the icons overlay the text
making it hard to read.

Is there a property or style sheet to adjust this?

For the currently selected its, the icon and text have good spacing
QComboBox.

Item icon overlays text.


I don't know what you did, but that's not how it normally looks. 
Obviously not.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] need advise on QStandardItemModel vs. QAbstractTableModel

2016-01-13 Thread Bo Thorsen

Hi Frank,

Den 12-01-2016 kl. 22:40 skrev Frank Rueter | OHUfx:

I just joined this list so hello everybody.
I'm using QT via PySide mainly to create tools for vfx workflows and
custom tools for the software Nuke.
<http://www.thefoundry.co.uk/products/nuke/>
I'm not a programmer by trade, more of a vfx artist and technician using
Python/PySide to enhance pipelines and workflows for myself and other
companies.
Currently I am writing a custom spreadsheet that will need many custom
ItemDelegates and a controlled way of data input/output when a cell's
data is changed.
I will also need to write a feature that allows for multiple cells to be
changed at the same time (haven't got that far yet though).

The amount of items will potentially be in the 100,000s and a lot of
filtering will be going on.

I started using the QStandardItemModel and so far things are working
fine, but I haven't implemented the delegates or editors yet, and I
believe I will also have to override the data()/setData() methods in
order to control how the data is managed on IO.

I can't make up my mind if I should switch to using the
QAbstractTableModel before proceeding.
I am using some of the QStandardItemModel's method's, such as clear()
and item() and setItem(), but I guess those are easy to re-implement.

The docs say that one should consider using QAbstractTableModel (or
QAbstractItemModel) for efficiency and flexibility, but I am struggling
to make an educated decision because I haven't used model/views often
enough yet to know about all the pros and cons, and I can't find a
discussion concerning this online.

I have started re-writeing the code using QAbstractTableModel, trying to
get to the same level I'm at with the code using the QStandardItemModel.
It seems a bit harder than I thought, but I will keep going for training
purposes if nothing else, hoping that I might even have a more
responsive model in the end, but I'm just not sure if it's worth it in
my case, or if I should just stick to the pre-fab QStandardItemModel.

Any advice from more experienced programmers on how to make that
decision would be very much appreciated. I'd hate to finish writing the
code only to find out that it's too slow for large data sets, and then
re-jig everything to use the QAbstractTableModel.


To me, the standard item model has always been something I use as little 
as I can. It's bad in so many ways. But I do understand why sometimes 
it's a quick fix for a small problem.


Implementing a proper table model is not as easy, but in the long run 
you will prefer it. Once a proper model is done, it just keeps working. 
And it can handle the large load you are talking about.


If it was me, I wouldn't have to think about this. It's a clear case of 
a proper table model.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] need advise on QStandardItemModel vs. QAbstractTableModel

2016-01-13 Thread Bo Thorsen



Den 13-01-2016 kl. 23:07 skrev Frank Rueter | OHUfx:

Thanks Bo,

when you say "it's bad in so many ways", are you referring to performance?

I just realised that my last conversation with Jason had dropped the CC
to the list, so here it is again :

so a few lines into the new code and I believe I'm starting to
realise that QAbstractTableModel is the wrong choice for me, let's
see if I get this right:

I need each cell to:

  * store a reference to a custom object in the host application
  * get it's background and foreground colour from the host
application's object
  * determine the right delegate output based on the data type/
external object class
  * drive the external object's value upon datatChanged
  * etc.

When I got as far as implementing the background role in my
QAbstractTableModel's data method, the resulting view took about 4
seconds to resize, while scrolling left me with the ol' spinning
beach ball (OSX).
The same code utilising QStandarItemModel reacts instantaneously
without trouble, even with way more data.

I suppose this is because I am storing those object references in
each QStandarItem as I construct the data when using
QStandarItemModel. So later on, those values are readily available
within my data model.
When putting those references into QAbstractTableModel.data(), they
are constantly called upon as the view changes, causing the massive
slow down.

In order to keep the view fast, I need to refactor my code and
somehow store the custom data only once, so things like background
colour etc. are determined within my model's data when needed,
rather than having to call the host application constantly to
retrieve the same info.
Which essentially turns the table model into an item model, and I
might as well use the QStandardItemModel or at least
QAbstractItemModel to begin with.

Does that sound about right?


Bo, reading your reply makes me feel like I should keep playing with
QAbstractTableModel (or QAbstractItemModel) and write all the behaviour
I need from QStandardItemModel myself?


Well, you almost already answered the question yourself. It's obvious 
your access from data() the real model is where the problem lies.



I feel like the item based approach is handier as I can subclass a
QStandardItem and give it a reference to the external object it
represents, then have the data read/write from/to that.
I don't think I get that with a table model unless I re-invent the wheel.


MyObject** references;

Can't be much faster than that.


Any thoughts on the above?


To me QStandardItemModel is a quick hack I sometimes use when I just 
want to show a bit on the screen. But those temporary things have a 
tendency to stick around, and at some point I always end up rewriting 
the stuff with the real thing.


If you have performance issues with a QAbstractTableModel over a 
QStandardItemModel, you're doing something wrong.


I think the only place where I might use a QStandardItemModel for 
something real is if you have a static set of information that you just 
need to show. If it never changes, then it's an easy model to use.


At the DevDays in 2006 (I think) I did a presentation on the model view 
classes. I basically told everyone that QStandardItemModel is the path 
to the dark side there as well. And one of the Trolltech guys came up 
and we had an interesting discussion about it. He did argue that 
sometimes there are cases where this makes sense.


But I'm biased. I hate that class and I really like the table and list 
model classes.


Bo.


On 13/01/16 10:27 pm, Bo Thorsen wrote:

Hi Frank,

Den 12-01-2016 kl. 22:40 skrev Frank Rueter | OHUfx:

I just joined this list so hello everybody.
I'm using QT via PySide mainly to create tools for vfx workflows and
custom tools for the software Nuke.
<http://www.thefoundry.co.uk/products/nuke/>
I'm not a programmer by trade, more of a vfx artist and technician using
Python/PySide to enhance pipelines and workflows for myself and other
companies.
Currently I am writing a custom spreadsheet that will need many custom
ItemDelegates and a controlled way of data input/output when a cell's
data is changed.
I will also need to write a feature that allows for multiple cells to be
changed at the same time (haven't got that far yet though).

The amount of items will potentially be in the 100,000s and a lot of
filtering will be going on.

I started using the QStandardItemModel and so far things are working
fine, but I haven't implemented the delegates or editors yet, and I
believe I will also have to override the data()/setData() methods in
order to control how the data is managed on IO.

I can't make up my mind if I should switch to using the
QAbstractTableModel before proceeding.
I am using some of the QStandardItemModel's method's, such as clear()
and item() and setItem(), but I gues

Re: [Interest] need advise on QStandardItemModel vs. QAbstractTableModel

2016-01-13 Thread Bo Thorsen

Den 13-01-2016 kl. 23:07 skrev Frank Rueter | OHUfx:

when you say "it's bad in so many ways", are you referring to performance?


Performance and ease of data manipulation are the two biggest points.

But it's really simpler than this. To use an old design phrase - that 
class just smells bad.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] 5.5/5.6 QMLEngine management

2016-01-10 Thread Bo Thorsen

Den 10-01-2016 kl. 03:21 skrev mark diener:

Hello List:

I have a couple of core QMLEngine questions:

Basic Code Snippet:

QQmlEngine geng ;

QQmlComponent gcomp()
gcomp.setData( ByteArrayofQML , QUrl() ) ;
gcomp.create() -> Show the QML in the QML Engine
if (gcomp.isError() == false) -> we have visible QML!

1) How does one cause all properties in the root context for QML
engine be triggered to re-evaluate their bindings again. For example
Text { text: gvariable }, it want text object to re-fetch its own
values instead of pushing values with Qobject->setProperty().  Generic
pull instead of specific push.

Can I cause a disturbance in the QmlContext and that would trigger and
"expensive" refetching of text values for example.


On one hand, this question doesn't make sense. QML vars are considered 
changed immediately, and that's a basic design choice.


OTOH, it's very simple to do this yourself. Just create a function that 
pulls in the new variable values. You might need a proxy object between 
the real value place and the QML land, but other than that you need no 
tricks for it.



2) How does one clear out everything loaded in the root QmlEngine context?

What is the best way to clear the root context of qmlengine of
everything prior to calling
gcomp->setData() and  gcomp->create( ) to load brand new QML into the QmlEngine?

geng->clearComponentCache() ?  Does this really flush everything out
regardless of anything that is currently visible on-screen?

I do not want to build up a pile of QObjects in the engine, I want
them cleanly flushed out.


Again, there are ways you could do this. Store the set of accepted vars 
and values and reset to exactly those when you want, for example.


But this idea smells badly of a fundamentally bad design. If you need to 
get rid of variables, reset them, etc. then they probably shouldn't be 
stored as context on the root engine. This sounds like one of the "how 
do I do B" because you are doing "A" already questions, and the problem 
is that "A" is wrong. We get those on this list all the time.


One idea I have used often is to have a backend object that is almost 
the only object exposed to QML. Inside this one you can set variables on 
the fly as you want. With the very limited amount of info you have given 
here this seems like a much more appropriate direction for you.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QTabWidget activity

2016-01-08 Thread Bo Thorsen

Den 07-01-2016 kl. 21:44 skrev Murphy, Sean:

I'm trying to figure out the right way to show some feedback to the user and 
I'm stuck. Here's the setup:
- I have a QTabWidget, that has three tabs, one for live data, one for archived 
data, and a third tab that doesn't having much to do with this particular 
issue, other than it exists.
- On the first tab we plot a live feed of data from a variety of sensors
   - Also on this tab, there is a "Take Snapshot" button
   - Pressing the "Take Snapshot" button should make a copy of the current plot 
data under the second tab while keeping the first tab (the live data) as the current tab 
index
- On the second tab, there's a child tab widget that shows the snapshots taken 
above, one snapshot per tab

This works fine, except that there's no real indication to the user that pressing the 
"Take Snapshot" button actually worked until the user clicks on the second tab 
and sees that the snapshot exists, so we'd like to add some sort of visual feedback that 
it was successful. Ideally, I'd like to blink the background color of *just* the second 
tab a couple times to let the user know something changed over there. But looking through 
QTabWidget, QTabBar, there doesn't seem to be any way of changing the background color of 
an specific, individual tab. I can change the text color of a specific tab using 
QTabBar::setTabTextColor(), but after trying that the effect is just a little too subtle. 
The closest thing I can find is through stylesheets using the QTabBar::tab:middle 
subcontrol and pseudostate, which I just luck out that it works for me because I only 
have 3 tabs, and I'm trying to change the middle tab. If we add more tabs later, that 
won't work, unless I switch it to using QTa
  bBar::tab:last and then change the behavior that the archived data is always 
on the last tab.

Are there other options to change the color, or does anyone else have a better 
idea of how to do provide feedback to the user? The only other viable options I 
see is that I could either:
  - change the text on the second tab to somehow reflect something changed 
(like add an * or something)
  - blink an icon on the second tab using QTabBar::setTabIcon(int index, const 
QIcon & icon)


I would probably prefer something like an overlay message popping up for 
a few seconds or (a bit nineties style) a status bar message. Another 
would be to have a subtle small icon overlay float from the button up to 
the tab.


I was trying to think if there were ways to hack around a QStyle proxy 
to do the flashy bit, but I'm not sure without spending a fair amount of 
time. The trick in this case is always the same idea:


1) Override only exactly what you need, in this case the drawing of a 
single tab.
2) Find a way to realize that you're currently painting the thing you 
want to change.
3) Override the painting of that single item, call the base class 
painter for all others.


This is a generic QStyle trick that can be used for many evil purposes. 
The problem with it is that it's quite hard to debug for anyone that 
doesn't know you have done it - imagine the poor developer going "where 
the f!#¤%& does that come from"? Hurting maintainability is usually a 
bad idea.


The trick has much more of an appeal if you already have a lot of QStyle 
stuff in your code.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] NUMA and processing groups

2015-12-22 Thread Bo Thorsen

Den 22-12-2015 kl. 12:05 skrev Etienne Sandré-Chardonnal:

I recently came across the following problem : my application, which
does heavy computing tasks distributed over multiple threads, uses
QThread::idealThreadCount() for deciding the optimal number of threads
on the system. One of my clients complained that the app was using only
50% of the cores on its system, and I found that this is due to the NUMA
architecture on the machine, which makes system calls used by
idealThreadCount return the number of cores in the current processing
group, and not the full system.

Is there any plan for implementing a NUMA API in Qt? As NUMA is the
future of many core architectures, it would be very interesting to have
a cross-platform API for this.


That's what they said in the nineties as well. Didn't happen so far. 
Although there are aspects of NUMA in all processors today, it seems the 
general consensus is that you need very specific cases for any affinity 
sensitive code to actually be faster.


That said, it's not great the the QThread ideal thread count isn't 
correct (assuming it isn't). If you want to investigate this issue and 
see if you can come up with a fix that doesn't break everything else...


If your system is special hardware, just set the number of threads manually.

Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] New CI for Qt (and OpenSource Qt/QtC 3rd parties)

2015-12-15 Thread Bo Thorsen

Den 11-12-2015 kl. 09:16 skrev Sarajärvi Tony:

> I cannot find any reference to "Coin CI".  Is this an open source or 
commercial tool?  A Qt internal tool?

Internal tool created from nothing. Sources aren't public as of yet anyway


I'd like to see that done. I'm also interested in hearing about why you 
chose to do this, as there are so many CI systems available already.


My guess is that this is because you want a system that can create 
virtual machines on the fly? I'd be interested in getting such a system 
set up for our own build server. So you could have your first 
contributor soon :)


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Question about setting QLocale

2015-12-01 Thread Bo Thorsen

Den 01-12-2015 kl. 16:02 skrev Murphy, Sean:

Den 30-11-2015 kl. 18:43 skrev Murphy, Sean:

I'm having an issue with multiple locales in my application and I'm
trying to understand what the best fix should be. Our application is
being used in two places right now: China & the US. One of the
functions of the application is to log data samples to a csv file.
Another function is to be able to load that log file back in later to
look at the data.


I fix this problem by setting the locale temporarily to a known state before
loading or saving files. This blog entry is about exactly this
problem: http://www.vikingsoft.eu/blog/?p=21

I hope this helps,


Thanks Bo! I think in my case the answer will be to modify my application to write out 
the data using a standard, locale agnostic format, so I could either use the QLocale::c() 
version or using Qt::ISODate or Qt::RFC2822Date. That fixes the problem going forward - 
new files will have date/time information written out the same regardless of the user's 
locale. Technically the way I was logging data was poorly thought out to begin with since 
it in no way accounted for timezones, I was writing the date/time out in "ddd 
MM/dd/ HH:mm:ss.zzz" format. So sure, you'd know that this sample was recorded 
on Monday, November 30, 2015 at 13:52:19.428 in someone's local time, but you would have 
no idea in what time zone that was done. Using Qt::ISODate or Qt::RFC2822Date fixes that 
for me.

Once I make that change, I only have to deal with existing files that were recorded under the old format where the date 
portion was done as "ddd MM/dd/". For those, it's really only the "ddd" part that is locale 
dependent and is screwing me up. That is redundant data anyways since I have the day, month, and year data right after 
it. So the easiest fix is to read in the string, remove the first 4 characters (the "ddd " portion) and then 
use QDateTime::fromString(data, "MM/dd/ HH:mm:ss.zzz") to read those in.


And then you have similar problems with QString::number, QDomDocument or 
any of the others that I have seen with this kind of problem.


Sure, you might test yourself all the way out of this to a working 
solution. And then in three years someone else uses QDate::toString the 
wrong way and you release the new version. And then you are ed again.


If you write something in a file that you later parse, you absolutely 
must set a known locale before the writing is done. Whether this is C 
(which is probably best) or US or anything else is irrelevant. As long 
as you do it.


Next step I'd do is to unit test this with something like

1) Set some weird locale
2) Call the write function
3) Set another weird locale
4) Call the read function

And repeat with a bunch of locale combinations. I'd also throw in a set 
of known good and bad files to test with.


With this, you will be fairly sure that your application won't ever 
bitrot in this area. Without it, there's pain waiting for you.


Bo.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Question about setting QLocale

2015-12-01 Thread Bo Thorsen

Den 30-11-2015 kl. 18:43 skrev Murphy, Sean:

I'm having an issue with multiple locales in my application and I'm
trying to understand what the best fix should be. Our application is
being used in two places right now: China & the US. One of the
functions of the application is to log data samples to a csv file.
Another function is to be able to load that log file back in later to
look at the data.


I fix this problem by setting the locale temporarily to a known state 
before loading or saving files. This blog entry is about exactly this 
problem: http://www.vikingsoft.eu/blog/?p=21


I hope this helps,

Bo.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] qmake's visual studio generator does not handle recursive subdir templates

2015-11-24 Thread Bo Thorsen

Den 24-11-2015 kl. 08:45 skrev Roland Winklmeier:

Am 24.11.2015 um 07:57 schrieb Bo Thorsen:

Den 23-11-2015 kl. 20:09 skrev Roland Winklmeier:

I'm working together with a team on a medium complex project. Our build
system is qmake and since some of us had previous experience with cmake,
we introduced a project structure with subdirs. It looks similar to the
following:

project.pro (subdirs)
|-- src.pro (subdirs)
  |-- lib1.pro (lib)
  |-- lib2.pro (lib)
  |-- plugins.pro (subdirs)
  |-- plugin1.pro (lib)
  |-- plugin2.pro (lib)
[...]

This gives us a nice hierarchical structure and all works nicely as long
as we use QtCreator. But some of us prefer to use native IDE's like
Visual Studio. When trying to create a Visual Studio solution from the
above (with qmake -tp vc -spec win32-msvc2013 -r), a *.sln is created
for each subdirs template instead of tracking them as child projects. So
project.sln does not contain any projects.

Do we hit a missing feature/bug in qmake or is it me using the subdirs
template incorrect?
I got the idea from qtbase which also has recursive subdirs.


This definitely works, I use it all the time. You need to show us some
of your pro files before we can help you.

Do you have "TEMPLATE = subdirs" in the file that has the SUBDIRS list?

Bo Thorsen,
Director, Viking Software.



Thanks everyone. After you confirmed that it should work, I had another
close look. I had the template = subdirs set, but qmake gives me
warnings [1] that it cannot find several *.vcxproj files. While
analyzing the logs, I found out that I used an out-of-source build and
qmake expected the *.vcxproj in the source folder instead of the build
folder. If I run the exact same command in the source folder, everything
is perfectly working as you said.

So I assume I just hit a small bug in qmake, that it cannot handle
out-of-source builds properly.


No again. I also use out of source all the time with subdirs on windows. 
Works fine. Show us your code if you want help. Please don't file 
bugreports on something that would obviously have been caught years ago 
if it didn't work.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] qmake's visual studio generator does not handle recursive subdir templates

2015-11-23 Thread Bo Thorsen

Den 23-11-2015 kl. 20:09 skrev Roland Winklmeier:

I'm working together with a team on a medium complex project. Our build
system is qmake and since some of us had previous experience with cmake,
we introduced a project structure with subdirs. It looks similar to the
following:

project.pro (subdirs)
|-- src.pro (subdirs)
 |-- lib1.pro (lib)
 |-- lib2.pro (lib)
 |-- plugins.pro (subdirs)
 |-- plugin1.pro (lib)
 |-- plugin2.pro (lib)
[...]

This gives us a nice hierarchical structure and all works nicely as long
as we use QtCreator. But some of us prefer to use native IDE's like
Visual Studio. When trying to create a Visual Studio solution from the
above (with qmake -tp vc -spec win32-msvc2013 -r), a *.sln is created
for each subdirs template instead of tracking them as child projects. So
project.sln does not contain any projects.

Do we hit a missing feature/bug in qmake or is it me using the subdirs
template incorrect?
I got the idea from qtbase which also has recursive subdirs.


This definitely works, I use it all the time. You need to show us some 
of your pro files before we can help you.


Do you have "TEMPLATE = subdirs" in the file that has the SUBDIRS list?

Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Putting a define with spaces in the .pro file?

2015-11-12 Thread Bo Thorsen

Hi Sean,

Den 13-11-2015 kl. 02:51 skrev Murphy, Sean:

I'm trying to add a defined string in my .pro file to be inserted by the 
preprocessor at compile time and I'm having trouble when it has spaces in it. 
Here's a really simplistic example:
[...]
But if I want my text to be a little more interesting and have spaces in it, it 
fails. Changing the DEFINES line in the .pro to:
   DEFINES += MY_STRING=\\\"Hello You\\\"
refuses to compile:
g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DMY_STRING=\"Hello -DYou\" 
-DQT_CORE_LIB -I..\testDefinesWithSpacesConsole -I"..\..\..\..\Qt_5_3_2\5.3\mingw482_32\include" 
-I"..\..\..\..\Qt_5_3_2\5.3\mingw482_32\include\QtCore" -I"debug" -I"." 
-I"..\..\..\..\Qt_5_3_2\5.3\mingw482_32\mkspecs\win32-g++" -o debug\main.o ..\testDefinesWithSpacesConsole\main.cpp
:0:11: warning: missing terminating " character [enabled by 
default]
:0:4: warning: missing terminating " character [enabled by 
default]
:0:4: warning: missing whitespace after the macro name [enabled 
by default]
..\testDefinesWithSpacesConsole\main.cpp:8:5: error: missing terminating " 
character
  qDebug() << QString(MY_STRING);
  ^
Makefile.Debug:190: recipe for target 'debug/main.o' failed
mingw32-make[1]: *** [debug/main.o] Error 1

So you can see that the string "Hello You" that I was trying to pass intact has 
now been split up into two different defines. Is there a way to get this to work?


My recommendation would be to go in a different direction. The only time 
I do stuff like this is when I add 3rd party code into my build trees. 
If this is your situation, then you probably have to do it.


If you can avoid this situation, put the possible set of defines in a 
file instead and make your DEFINES choose from the set.


If not, you can always add the c++ compile flag yourself. You don't have 
to use DEFINES, this is just a compiler agnostic way of adding defines. 
Of course, you would have to do this for every compiler you use, but 
these days that's usually max three.


Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] A QThread question...

2015-10-21 Thread Bo Thorsen
Den 21-10-2015 kl. 11:48 skrev NoMercy:
> Hello everyone and thanks for you replies,
>
> I've a rather advaced question about QThreads (well advanced to my
> knowledge anyways)
>
> I have a Windows service that runs under System user (naturally) but I
> want to create and run a thread from within that service and change the
> token of that thread so it runs in user evironment.
>
> and to do so, I thought of something like this;
> get QThread::currentThreadId -- Documentation says do not use it but?
> get handle of that thread by OpenThread(threadID)
> and use SetThreadToken to move thread to user space.
>
> I'm using 4.8.6 btw
>
> do you think it is possible?
> is this approach safe?
> would it be stable?
> any possible implications?
> if it works, would my main thread can still comunicate through
> signals/slots?

If you are going to do native stuff to the threads, then I think you 
would be wise to create the thread with the native windows calls for it 
instead of trying to bend a QThread to the rules.

The whole notion of threads running as a separate user feels like such a 
dirty solution anyway, and QThread might muddy the waters even more. For 
example, signal from one user thread to a slot in a thread running as 
another user... It just gets weird.

Keep it simple, create the thread yourself and separate this completely.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] constraining minimum widget size

2015-09-23 Thread Bo Thorsen
Den 23-09-2015 kl. 09:07 skrev Hamish Moffatt:
> I want to be able to set the minimum size for a container widget without
> ignoring the minimum sizes of the children. ie I want to constrain the
> minimum size of the container, not override it. Is this possible?
>
> Here's what I mean. Let's say I have a QFrame with a QVBoxLayout
> containing a couple of widgets, for example QRadioButton. I want this
> QFrame to be a particular size, no smaller (it looks silly), big enough
> to contain the child widgets, but no bigger. The size policies on the
> frame and radio buttons are all minimum.
>
> If I set the minimumSize property on the QFrame, I get the minimum size
> I requested - but now the QFrame ignores the minimum sizes of the
> children, so if the children require more room they are clipped. For
> example if the user is using 150% font scaling in Windows...
>
> Examples: no minimum size, with a minimum size set, with the minimum
> size set but larger fonts...
>
> If I were writing a custom widget then overriding
> sizeHint()/minimumSizeHint() might help, but I want to do this in Qt
> Designer/Creator using the standard container widgets. Is it possible?

Yes it is.

The stacked widget is useful for many things, this is one of them.

Create a stacked widget with two pages. Page 1 has all the widgets you 
need for this page, so it's just a container for them. On page 2 you put 
an empty QWidget inside with the minimum size you want. You never show 
page 2, but the minimum size is used.

The stacked widget minimum size is just the maximum of each pages 
minimum size, which is exactly what you want here.

I hope this helps,

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Loader refresh

2015-09-15 Thread Bo Thorsen
If it's just about language changes, it's pretty easy to fix. Just add a 
function that updates the string on each text item. Exactly like a 
ui_xx.h file does it.

One hack I've seen but never tried is to have a c++ object that has a 
string property. The property is actually always empty, but on language 
switches the c++ object emits the property changed signal. In the qml 
code you do this:

Text { text: qsTr("foo") + cppObject.emptyString }

As I said, I never tried this, because it smells a bit.

My preferred method of doing live language switches in qml is to have a 
translate function on every page that sets all strings.

You most definitely do not reload the loader ever just to work around 
something. The loader is for switching the page it holds, not anything else.

Bo.

Den 14-09-2015 kl. 17:02 skrev m...@rpzdesign.com:
> Bo:
>
> Thanks for the response.
>
> The only other areas that I can see needing a screen refresh are
> ListView and Image (Imageprovider)
>
> The Text QML object was shared as one example of "changing" after the
> loader is when you swap out the language from English to Chinese to Arabic.
>
> I think this is where we mis-understand each other.  What are my
> Post-Loader options, not pre-loader.
>
> The only way I can see now to "reload" using loader, but it is not very
> smooth.
>
> And the component cache will suppress the repeated loading of the same
> QmlComponent object after 1 refresh.
>
> So then you are really forced to make the QML stack see a new
> Component so the loading is forced to take.  And that heavy handed
> requirement causes quite a lot of screen flicker.
>
> So I would chalk this up to the inability right now to force the QML
> engine to Repaint itself.
>
> Yes, I know, the rebuilding the Scene graph would be expensive, but that
> is what I would like to do in a generic way instead of having to set the
> text individually for each component (Since each one loads itself based
> on Country Language)
>
> Kind of a catch-22 for text objects based on displayed language.
>
> Maybe Microsoft flickers when it changes its display language, so I will
> just do the same.
>
> Cheers,
>
> md
>
>
> On 9/14/2015 1:11 AM, Bo Thorsen wrote:
>> Hi md,
>>
>> I don't know what it is you see, you just say it flickers. We use a lot
>> of Loader objects for customer code, and that doesn't flicker.
>>
>> The only guess I have on how this could happen is if you have lots of
>> bindings that keep propagating through the system.
>>
>> For example, you mentioned a Text object that switches from one string
>> to another. This is an indication that your code is the reason for those
>> problems. When you activate the loader, set the proper text immediately,
>> don't switch it later.
>>
>> Anything like what you're trying to do below is an attempt to solve the
>> symptom rather than the problem.
>>
>> Den 11-09-2015 kl. 20:37 skrev m...@rpzdesign.com:
>>> Someone must have come across this problem before.
>>>
>>> Loader->sourceComponent is too heavy and causes screen flicker.
>>>
>>> QMetaObject::invokeMethod(gobj,"doLayout",Qt::QueuedConnection) does not
>>> work on QQuickText class objects.
>>
>> Bo Thorsen,
>> Director, Viking Software.
>>
>

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Loader refresh

2015-09-14 Thread Bo Thorsen
Hi md,

I don't know what it is you see, you just say it flickers. We use a lot 
of Loader objects for customer code, and that doesn't flicker.

The only guess I have on how this could happen is if you have lots of 
bindings that keep propagating through the system.

For example, you mentioned a Text object that switches from one string 
to another. This is an indication that your code is the reason for those 
problems. When you activate the loader, set the proper text immediately, 
don't switch it later.

Anything like what you're trying to do below is an attempt to solve the 
symptom rather than the problem.

Den 11-09-2015 kl. 20:37 skrev m...@rpzdesign.com:
> Someone must have come across this problem before.
>
> Loader->sourceComponent is too heavy and causes screen flicker.
>
> QMetaObject::invokeMethod(gobj,"doLayout",Qt::QueuedConnection) does not
> work on QQuickText class objects.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt 5.5.x

2015-09-14 Thread Bo Thorsen
Den 12-09-2015 kl. 10:19 skrev Till Oliver Knoll:
>
> Am 11.09.2015 um 19:59 schrieb Matthew Woehlke <mwoehlke.fl...@gmail.com
> <mailto:mwoehlke.fl...@gmail.com>>:
>
>> On 2015-09-11 13:41, Till Oliver Knoll wrote:
>>> You can further reduce the "dependency tree" of your sources by
>>> making use of the private "d-pointer" pattern (there is a name for
>>> it which currently escapes me)
>>
>> PIMPL? ;-)
>>
>> https://en.wikipedia.org/wiki/Pimpl
>
> Exactly :) Even though I had the term "Cheshire Cat" in mind :) (I yet
> have to google why that pattern is named after a cat).
>
> But while we're there, quoting from that article:
>
> "One type of opaque pointer commonly used in C++ class declarations is
> the d-pointer. The d-pointer is the only private data member of the
> class and points to an instance of a struct. Named by Arnt Gulbrandsen
> <https://en.m.wikipedia.org/w/index.php?title=Arnt_Gulbrandsen=edit=1>
>  of
> Trolltech <https://en.m.wikipedia.org/wiki/Trolltech>, this method
> allows class declarations to omit private data members, except for the
> d-pointer itself.^[6]
> <https://en.m.wikipedia.org/wiki/Pimpl#cite_note-6>  The result: (a)
> more of the class implementation is hidden from view; (b) adding new
> data members to the private struct does not affect binary compatibility;
> (c) the header file containing the class declaration only needs to
> #include those other files needed for the class interface, rather than
> for its implementation. One side benefit is that compilations are faster
> because the header file changes less often. The d-pointer is heavily
> used in the Qt <https://en.m.wikipedia.org/wiki/Qt_(toolkit)> and KDE
> <https://en.m.wikipedia.org/wiki/KDE> libraries."

There is another term used for it as well: Compiler firewall. The 
d-pointers make it impossible for the compiler to perform a long list of 
optimizations.

I value using d-pointers over raw speed for most cases. But it's one 
thing to keep in mind if you really have to optimize.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Handling QObject auto-deletion and signals emitted from destructors

2015-09-04 Thread Bo Thorsen
If your question is only about the generic question and not about the 
code, skip to the bottom of my reply. If it's about the actual code you 
posted, keep reading :)

Your problem is that you call a method on an object that's deleted. In 
this code:

connect(webview, ::destroyed, [this] () {
   // replicate loadFinished being fired during qwebview/webpage destruction
   emit webview->loadFinished(false);
});

This is completely wrong. When destroyed is emitted, the QWebView object 
is already "deleted" (i.e. the destructor has been called) and only the 
QObject part of it remain. Calling a method on such a half object is doomed.

I don't understand why you don't just call onLoadFinished(whatever) 
instead of trying to replicate anything. This is what you need to do.

There are some things you can do to an object in a slot that's direct 
connected to the destroyed signal. But it's a good general rule for 
anyone that you just can't do anything to it. Unless you really know 
what you are doing, you are going to get into trouble with this. And I 
don't think I've ever needed to do this. Accept that the object is gone 
and fix the code to handle this.

Another thing with your code: Why do you even want to do this? If the 
web view is destroyed, that means the entire widget is destroyed. So why 
do you need to set anything on the other widgets?

And now for the general answer: You are in trouble here. Yes, a QPointer 
is the way to track if an object is deleted or not, and I don't see how 
that's tedious. However, when you are mixing a slot connected to 
destroyed and QPointers, you start depending on the order of slots 
called. To avoid this, I'd use a queued signal or handle it in some 
other way. For this, we need actual code to help.

Bo.

Den 01-09-2015 kl. 17:06 skrev Neil Williams:
> Below is a example program which will crash when the widget is closed.
>
> This setup replicates the QWebview behaviour where it will emit the
> loadFinished signal from inside the destructor if a page is loading.
>
> I am wondering if anyone can suggest a clean way of handling this sort
> of case, where a sibling may have been deleted but is referenced in a
> connected slot of a non-deleted object.
>
> I have considered:
>
> 1. Always using QPointer and check for object validity before accessing
> in the slot. This seems like it would be somewhat tedious.
>
> 2. Using the 'context' param of QObject::connect override and splitting
> the current slot into multiple smaller slots that only access a single
> param, e.g:
>
> connect(webview,::loadFinished, ok_widget, [this] (boolok) {
>
> ok_widget->setVisible(ok);
>
> });
>
>
> connect(webview,::loadFinished, fail_widget, [this] (boolok) {
>
> fail_widget->setVisible(!ok);
>
> });
>
>
> This requires more boilerplate and may not be possible for more complex
> slots which need to access multiple objects.
>
>
> 3. Call to QObject::disconnect in the containing class destructor. This
> does feel a little bit like I am micro-managing the connections which
> would be nice to avoid.
>
>
> 4. Switch to manual memory management of the widgets so I can control
> destruction order.
>
>
> At the moment I am considering either 1, 3 or 4 but I would appreciate
> any other views/opinions/suggestions.
>
> Thanks.
>
> #ifndefWIDGET_H
>
> #defineWIDGET_H
>
>
> #include
>
> #include
>
> #include
>
> #include
>
>
> classQWebView;
>
>
> classWidget:publicQWidget
>
> {
>
> Q_OBJECT
>
>
> public:
>
> explicitWidget(){
>
>
> QVBoxLayout*layout=newQVBoxLayout();
>
>
> webview=newQWebView();
>
> ok_widget=newQWidget();
>
> fail_widget=newQWidget();
>
>
> connect(webview,::destroyed,[this](){
>
> //replicateloadFinishedbeingfiredduringqwebview/webpagedestruction
>
> emitwebview->loadFinished(false);
>
> });
>
>
> connect(webview,::loadFinished,this,::onLoadFinished);
>
>
> layout->addWidget(ok_widget);
>
> layout->addWidget(fail_widget);
>
> layout->addWidget(webview);
>
>
> setLayout(layout);
>
> }
>
>
> ~Widget(){
>
> qDebug()<<"Windowdestroyed";
>
> }
>
>
> privateslots:
>
> voidonLoadFinished(boolok){
>
> ok_widget->setVisible(ok);
>
> fail_widget->setVisible(!ok);
>
> }
>
>
> private:
>
> QWebView*webview;
>
> QWidget*ok_widget;
>
> QWidget*fail_widget;
>
>
> };
>
>
> #endif//WIDGET_H
>
>
>
>
> ___
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Windows deployment. Failed to start because of missing platform plugin...

2015-08-30 Thread Bo Thorsen
Den 29-08-2015 kl. 12:34 skrev Peter Kümmel:
 Deploying a MSVC build is a bit annoying because of this
 redistributable stuff. Didn't it require admin rights for installing?
 In corporations a user often does not have enough rights for
 installing software.

One way to work around this is to copy msvcp120.dll and msvcr120.dll 
(numbers vary with the VS version) into the application dir together 
with the rest of the dll's you need. With Qt applications you usually 
only need those two. You can also link with the runtime statically, but 
I haven't met many Qt applications that do this.

Another reason why I finally chose this way is that users might 
uninstall the redist package (thinking they don't know what that is and 
don't need it) and then my software fails.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Windows deployment. Failed to start because of missing platform plugin...

2015-08-28 Thread Bo Thorsen
Den 28-08-2015 kl. 10:01 skrev Igor Mironchik:
 I'm trying to deploy Qt Windows application. And it failed to start with
 the next message...

 This application failed to start because it could not find or load the
 Qt platform plugin windows.

 Reinstalling the application may fix this problem.

 Platform plugin is exist in ./platforms/qwindows.dll

It has to be in plugins/platforms/qwindows.dll.

 How can I solve this problem?

When I hit this, I copy every dll from Qt to my bin dir and every plugin 
to the plugins dir. If that runs, then you can start deleting stuff and 
see if your application still runs.

For example, I have this:

C:\Prog..\VikingSoftware\Pokerformance\
   pokerformance.exe
   Qt5Core.dll
   Qt5Gui.dll
   Qt5Network.dll
   Qt5Sql.dll
   Qt5Widgets.dll
   plugins\
 platforms\
   qwindows.dll
 sqldrivers\
   qsqlite.dll

This works for me with Qt 5.5.

I hope this helps.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Windows deployment. Failed to start because of missing platform plugin...

2015-08-28 Thread Bo Thorsen
Yes, although this is frowned upon. You are supposed to install the 
redist package from VS instead.

But I also choose to deliver those as well as the SSL libraries.

Bo.

Den 28-08-2015 kl. 16:41 skrev Henry Skoglund:
 Hi,

 also qwindows.dll depends on MSVCR120.DLL and MSVCP120.DLL (for
 VS2013-flavored Qt), if the target system lacks those you need to copy
 them together with your .exe file.

 Rgrds Henry

 On 2015-08-28 15:42, Samuel Gaist wrote:

 On 28 août 2015, at 15:20, Bo Thorsen b...@vikingsoft.eu wrote:

 Den 28-08-2015 kl. 10:01 skrev Igor Mironchik:
 I'm trying to deploy Qt Windows application. And it failed to start with
 the next message...

 This application failed to start because it could not find or load the
 Qt platform plugin windows.

 Reinstalling the application may fix this problem.

 Platform plugin is exist in ./platforms/qwindows.dll

 It has to be in plugins/platforms/qwindows.dll.

 How can I solve this problem?

 When I hit this, I copy every dll from Qt to my bin dir and every plugin
 to the plugins dir. If that runs, then you can start deleting stuff and
 see if your application still runs.

 For example, I have this:

 C:\Prog..\VikingSoftware\Pokerformance\
 pokerformance.exe
 Qt5Core.dll
 Qt5Gui.dll
 Qt5Network.dll
 Qt5Sql.dll
 Qt5Widgets.dll
 plugins\
   platforms\
 qwindows.dll
   sqldrivers\
 qsqlite.dll

 This works for me with Qt 5.5.

 I hope this helps.

 Bo Thorsen,
 Director, Viking Software.

 --
 Viking Software
 Qt and C++ developers for hire
 http://www.vikingsoft.eu


 Hi,

 There's also windeployqt that can help for that matters

 Cheers
 Samuel

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



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


Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Windows deployment. Failed to start because of missing platform plugin...

2015-08-28 Thread Bo Thorsen
Den 28-08-2015 kl. 17:24 skrev Sze Howe Koh:
 plugins\
   platforms\
 qwindows.dll
   sqldrivers\
 qsqlite.dll
 
 This works for me with Qt 5.5.
 Are you sure? Did you use a custom configuration or call
 QCoreApplication::addLibraryPath()? By default, the application will
 look for PWD\platforms\qwindows.dll but not
 PWD\plugins\platforms\qwindows.dll.

Oops, I forgot to mention that I also ship a qt.conf that sets the path 
to . - that's what makes this possible.

I just checked on a clean virtual machine. If I remove the qt.conf it 
doesn't work, like you predicted. Moving the two plugins dirs to the 
toplevel does.

But the point of my first mail was actually not this one. It's more to 
try and copy over all the dll's and all plugins and see if you can make 
this work. If you can, then it's a question of missing dependencies on 
Igors side. If not, there's something not Qt related that stops this. 
But as it complained about the windows plugin, it's a very safe bet that 
it's either the plugins dir locations or some missing libraries.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Need argumentative help..... giving qobject copy/assignment constructor and put it in qlist/qmap

2015-07-23 Thread Bo Thorsen
Den 23-07-2015 kl. 07:57 skrev Gunnar Roth:

 Am 23.07.2015 um 07:51 schrieb Bo Thorsen b...@vikingsoft.eu
 mailto:b...@vikingsoft.eu:

 Den 23-07-2015 kl. 00:07 skrev Thiago Macieira:
 Disabling C4244 /* conversion from 'type1' to 'type2', possible loss
 of data
 */ is more than going to far. It is kind of sabotage imho.
 Note that this does not apply to 64-bit to 32-bit conversions. Those
 are still
 active, so C4244 does not seem to apply to them. I don't know what it
 applies
 to.

 I think this one warns on float f = 2.0;.

 In this particular instance, it's pretty dumb. 2.0 is perfectly fine
 inside a float. But it just warns every time you store a double in a
 float without trying to be clever about when you should receive the
 warning.

 I think, reading documentation is better than thinking ;-)

 https://msdn.microsoft.com/en-us/library/2d7604yb.aspx

I know, but Thiago said he hadn't seen it actually do any warnings. And 
I agree with him that I haven't seen it warn about integer types.

In one of my customer projects I ported their project to Windows and got 
thousands of the double to float warnings, which is why I mentioned that 
it certainly does do something.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QMainWindow state resetting

2015-07-23 Thread Bo Thorsen
Den 23-07-2015 kl. 07:51 skrev Berkay Elbir:
 I'm searching is there a way to reset to default state of QMainWindow at
 runtime?
 I have a QMainWindow that has some widgets, user can customize their
 locations and save them.
 But I want to put a button that resets window states and reverts back to
 default mode at runtime like
 reset window layout option in visual studio.

 Anybody did this before?

Hi BE,

There is no reset() method on QMainWindow.

However, there might be a way to do it anyway. I haven't tried this, but 
it's what I would do for the first attempt if I had to implement it.

On startup store the state of the window at the point where you to 
restore it to. You use saveState() and saveGeometry() for this. When 
you want to reset it, call restoreState() and restoreGeometry().

You can see examples of this in the QMainWindow documentation. The 
examples store the values in QSettings because this is almost always 
used to restore the window the next time the user starts the 
applicaiton. But it should be simple for you to adjust this to your problem.

I hope this helps.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Need argumentative help..... giving qobject copy/assignment constructor and put it in qlist/qmap

2015-07-22 Thread Bo Thorsen
Den 20-07-2015 kl. 14:51 skrev Guido Seifert:
 Hi, just seen this in project's code. Worse, I have been told to do it
 exactly this way in another code part. I must say I am less than
 thrilled. On first glance this code seems to work. There is not much
 copying around. The objects sit happily in their containers. But it
 smells. So what is the worst what can be expected? Something not
 obvious? On different compilers? I need some convincing reasons, which
 cannot just waved away. or confirmation that eveything is fine and I
 can stop worrying but this also must be convincing. Perhaps even
 more ;-)

The problem with this kind of bad hack that people judge it on whether 
or not they could get away with it. It compiles? Ship it!

I think your problem is that your spidey sense is ringing so hard that 
you lost the ability to give arguments about this :)

The problem you have is that it can actually work, as long as they don't 
use the memory management of QObject. So if the counter argument is we 
won't do that, (which is probably the case) and this argument is 
accepted by the management, then you have a problem. Or rather, your 
customer has a problem that goes deeper than the current piece of code.

In addition to the technical arguments that you already got on 
parent-child ownership, signal-slot connections and threats, there are a 
couple more here:

1) Every subclass of QObject assumes it can't be copied. Unless they 
went into every direct subclass and explicitly disabled copying, that is 
now allowed for all of them. Both for all Qt subclasses and QObject 
subclasses in their own code. Good luck catching the crashes from this.

2) When someone introduces code that relies on other developers to not 
use a set of features or it breaks, that is a perfect recipe for 
maintenance hell.

3) They need a patched Qt for all future. Ask their manager to calculate 
the cost of this. Even if they currently have other Qt patches, that 
doesn't mean they will in the future, because it's impossible that this 
change will ever be accepted in Qt itself. This also means shipping the 
patched Qt sources if they use one of the OSS licenses.

4) Even though it might accidentally work right now, there's obviously 
no guarantee that it will in the future. So they might end up stuck with 
a Qt version unless they fix their code anyway.

I would also identify the people who did this change, because I would 
not trust any judgement on their side, so any code change from them is 
considered suspect. This is such a horrible idea that it shows a 
fundamentally flawed ability to make design choices.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Need argumentative help..... giving qobject copy/assignment constructor and put it in qlist/qmap

2015-07-22 Thread Bo Thorsen
Den 23-07-2015 kl. 00:07 skrev Thiago Macieira:
 Disabling C4244 /* conversion from 'type1' to 'type2', possible loss of data
 */ is more than going to far. It is kind of sabotage imho.
 Note that this does not apply to 64-bit to 32-bit conversions. Those are still
 active, so C4244 does not seem to apply to them. I don't know what it applies
 to.

I think this one warns on float f = 2.0;.

In this particular instance, it's pretty dumb. 2.0 is perfectly fine 
inside a float. But it just warns every time you store a double in a 
float without trying to be clever about when you should receive the warning.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] uic plugin path

2015-07-16 Thread Bo Thorsen
I have a designer plugin that I would like to use as part of the build 
process. The plugin is built before the uic is called for the first time.

In Qt 4, I could call uic with -L, but that has been removed from uic in 
Qt 5.

Must I install the plugin to qtdir/plugins/designer before doing this or 
is there some way to do it?

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt jobs mailing list

2015-06-22 Thread Bo Thorsen
Hi Donald,

Den 23-06-2015 kl. 04:24 skrev Donald Carr:
 I am surprised that we never considered opening a mailing list to
 facilitate the global advertising of Qt related development positions.
 We are a small community, I would think we would benefit from providing
 a single centralized point of sourcing/advertising positions.

No mailing lists, but there are three forums. And for jobs, forums seem 
like a better way to do it.

http://forum.qt.io/category/23/jobs
http://www.qtforum.org/forum/18/commercial-jobs.html
http://www.qtcentre.org/forums/12-Jobs

Let your friends know about those.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Legal: Using Qt examples in commercial closed source applications

2015-06-22 Thread Bo Thorsen
Den 22-06-2015 kl. 14:45 skrev Rainer Wiesenfarth:
 We would like to include a code snippet of the Qt examples in our commercial
 closed source application. The file containing this code is published under
 the BSD license. We ourselves hold commercial licenses of Qt.

 Question: Do we have to follow the BSD license terms, namely the
 Redistributions in binary form must reproduce the above copyright notice,
 this list of conditions and the following disclaimer in the documentation
 and/or other materials provided with the distribution. or is this covered
 by our commercial license?

Must be said: IANAL.

There's no way the QtCompany lawyers will allow you to relicense parts 
of Qt as BSD code, so you can't copy the code into that file.

Copying Qt code parts to your own code is a very grey area and I wish 
there would be some sort of guidelines from QtC about what they allow. 
But I can understand why they don't do this - there are multiple and 
very ugly cans of worms waiting for them if they would do it.

The best way to do this is usually to place the code in a separate 
library with a very clear license.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Building a large desktop application with QML/QtQuick?

2015-06-21 Thread Bo Thorsen
Hi Russel,

Den 19-06-2015 kl. 21:00 skrev Russell Warren:
 I'm contemplating making a large/monolothic/modular desktop application
 with QML/QtQuick.  The application would be a client-side application
 for a back-end server with a lot of data.  There will be a wide variety
 of interfaces to manage, including: many forms for creating/modifying
 various server-side objects; a large number of table/treeview displays
 for exploring data, and many varieties of interactive graphs/charts.
 Data viewing must scale up to millions of data points of diverse
 types... ListView, TableView, and the new TreeView controls would
 definitely be heavily used.  It is also worth saying that the control
 count/density would be pretty high. Portions of the application would be
 like an IDE, or like Excel (but JMP [1] is a better example).

 Starting proof of concepts with QML look really promising.  In
 particular, the GUI design/layout model is so enjoyable that reverting
 back to Qt Widgets development feels clunky and old (I hate to say
 that... I love Qt Widgets!).  QML works very nicely.  Binding on its own
 is awesome.

 However, before a more significant investment into the QtQuick path, I
 figured it was worth asking a few questions on this list:

  1. Can anyone think of any fundamental reason to NOT do the interface
 with QML? ie: Any compelling reasons that we should stick with
 old-school Qt Widgets?

Yes, there are a lot of reasons. But also reasons for moving to QML. 
Here are some of the problems you will face:

1) Maintaining large QML applications seems to result in more bit-rot 
than widgets based code. Some of this comes from the language being much 
less structured

2) Refactoring QML code is much harder than refactoring C++ code

3) Avoid large QML file like the plague. I have inherited a customer 
application with a 5000 line QML file in. If it had been written 
properly in the first page, it should be at least 5 different files. But 
see 2) for the reason I haven't split it up

4) Performance of loading large QML application is bad, so you have to 
use loaders and other ways to minimize startup time. That makes the code 
harder to do

5) The language itself has the problem that there's no separation of 
data and presentation. You must make sure that this happens or you end 
up with massive problems

6) The JMP application looks like a desktop application. QML is ideal 
for making embedded application with custom look and feel. That's not 
what you are doing

7) Tooling of QML is still almost non existant, which for small 
application is less of an issue. But with a large one, printf debugging 
is really sad. GammaRay might help, but only for some sets of problems

8) The components are IMHO still only a toy (to me, if something is 90% 
done, it's not done). Those would have been perfect for you

  2. Does anyone know of any existing examples of large applications
 built with QtQuick?

Yes I have worked on several for different customers. Two desktop 
applications and the rest embedded applications.

I tend to say desktop applications should be done with widgets and 
embedded with QML. But the real split should be: Custom look'n'feel or 
stuff that runs on phones: QML. Standard office like applications: Widgets.

And of course then there are a long list of real pros and cons. Those 
are only the first guideline for the choice.

  3. Does anyone know of any good resources on structuring large QtQuick
 applications?

I did a talk on DevDays about that exact topic. It was called something 
like QML Judgement Day. You should be able to find the slides and the 
talk on the dev days site.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt5 with qml 2.x on Windows XP... problems?

2015-06-10 Thread Bo Thorsen
Den 10-06-2015 kl. 22:31 skrev Guido Seifert:


 Thanks for clarifying that. So it seems unless your embedded XP systems have 
 after market 3D graphics cards, you can't succeed in the move to QtQ2.
 If you can upgrade those systems (Are the AGP? or PCI? (You can get a video 
 card that will likely work for about $25-$45 USD) )

 Thank you (and all the others, who answered). This is exactly, what I 
 expected. Today was my first day on that project. And when they told me they 
 would like to upgrade, but still have XP systems, which has to be supported, 
 immediately some alarms went off in my head. But Windows isn't my preferred 
 system, especially nothing before Windows 7, so I wanted some confirmation.

 Since I am so 'fresh' in this team, I cannot give more information about the 
 exact hardware and driver situation.

One thing you could tell them is that they should be able to upgrade to 
Qt 5 if they keep using Qt Quick 1.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QML Listview delegate in C++

2015-06-06 Thread Bo Thorsen
Den 05-06-2015 kl. 23:04 skrev Simone:
 I'm facing a problem in my QML application. The target is an Arrm processor

Ah, the pirate processor :)

 (freescale iMX53) with not so much capabilities.
 My problem is that I have a quite complex listview delegate item, and I 
 observe a cpu usage very high when scrolling my list with lot of items, 
 penalyzing the smoothness of the scrolling.
 I was wondering if I can develop the delegate in C++ (with widgets) instead 
 of pure QML since the creation of QML objects is (of course) slower.

No, you can't use widgets for this. Technically that might not be 
entirely accurate, but since we're talking performance, it is.

What you can do instead is to create a new kind of item yourself by 
subclassing QQuickItem and using native OpenGL rendering to do this. 
There are examples in the Qt dir that shows how to do this. You can also 
watch a talk from last years dev days about how to do this.

If you create a single item delegate that performs the entire painting 
without creating other objects, you probably can't do better. Now, 
wether this actually solves your problem

 Is there such possibility?
 Can I reasonably increase scroll performances?

Yes, that should be possible. I was not sure if the delegate was 
instantiated multiple times or reused, but a quick test with this shows 
that it's actually created over and over again:

import QtQuick 2.2

Rectangle {
 width: 360
 height: 360

 property int delegateCount: 0

 Component {
 id: itemDelegate
 Text {
 text: I am item number:  + index
 Component.onCompleted: console.log(Instantiated delegate, 
++delegateCount)
 }
 }

 ListView {
 anchors.fill: parent
 model: 100
 delegate: itemDelegate
 }
}

I hope this helps,

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Showing QGuiApplication/QML application on a given HWND ref.

2015-06-03 Thread Bo Thorsen
Den 03-06-2015 kl. 12:35 skrev Nuno Santos:
 Thanks for sharing your code.

 I will try and give some feedback.

 Any thoughts regarding the initial approach? Is there any reason for you
 not having followed that path?

My application inserts an overlay over a complete unrelated application 
(the pokerstars or bet365 poker clients actually), so this is the only 
approach that can work.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Showing QGuiApplication/QML application on a given HWND ref.

2015-06-03 Thread Bo Thorsen
Den 03-06-2015 kl. 08:56 skrev Nuno Santos:
 When we start a new QGuiApplication, it handles the Window creation on each 
 platform.

 Now imagine that someone would give us a window ref and we wanted to put our 
 Qt application running on it.

 Is this possible?

 I’m building a plugin for an host program that provides the window for the 
 plugin to be shown, but Qt already opens an window.

 Apparently it is not possible to control if that window is provide or not. It 
 seems to be always provided.

In one of my projects I use the Windows setParent() function to inject 
my window over the other applications native window. My window is a 
transparent overlay over the other window. Works perfectly.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] SQLite

2015-05-27 Thread Bo Thorsen
Den 27-05-2015 kl. 10:51 skrev André Somers:
 Graham Labdon schreef op 27-5-2015 om 09:39:
 Hi
 I am planning to use a SQLite database in my application to store 
 application data.
 The application is large and complex so we are taking a phased delivery 
 approach. This will mean that the structure of the database will change over 
 time and that we need to provide backwards compatibility.
 So, what I need is some way to create a versioning system and a way of 
 converting old format databases to the current format.
 I would be grateful if anyone could suggest a good approach to this

 Thanks
 ___
 Interest mailing list
 Interest@qt-project.org
 http://lists.qt-project.org/mailman/listinfo/interest
 
 We do it manually. We keep a data version number in the database
 properties, which you can set and get via a pragma. Then, we have a list
 of updater objects that can update a database from one version to the/a
 next using a script. For every database change we need to make, we up
 the version number we expect, update the code to create a new database
 and write an updater script from the previous version. We run the
 scripts we need to update to the version expected by the software at
 startup. So, if you run the software against a version 7 database and
 the software expects version 10, it will go through the scripts looking
 for a script that updates version 7. The updater that takes a version 7
 then updates to version 8, so the software will look for a script that
 takes a version 8 database. This updater can then update to version 10
 in for instance, skipping version 9 that may have been faulty in some
 sense. It is quite easy to extend and reasonably flexible in terms of
 making it possible to create scripts that skip version numbers if that
 makes sense, but not make it mandatory to write a separate script
 between each possible version.

 Note that we don't support going backwards. That sometimes causes
 problems when clients want to reinstall a previous version because of
 some regression.

I have a similar approach to this, except that I code generate the db 
code. Some tables can be generated based on the contents of other 
tables, so those are just wiped when upgrading a table to a new version. 
For those that can't be generated, I have to implement an upgrade function.

I have been meaning to clean this up a bit and allow others to use it, 
but so far haven't found the time.

Graham (or anyone else who might be interested), if you want to see it, 
I could send you the sources for the code generator.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Is QLocalSocket reentrant?

2015-05-27 Thread Bo Thorsen
Den 22-05-2015 kl. 14:43 skrev Calogero Mauceri:


 Il 5/22/2015 2:35 PM, Calogero Mauceri ha scritto:
 Hi all,

 sorry if this is a stupid question, but I'm having some weird memory
 corruption problems when using QLocalSocket in multiple threads.

 I have a server process, accepting connections from client processes
 through a QLocalServer instance. Every time a new connection is accepted
 by the QLocalServer, the server launches a thread that communicates with
 the client through the QLocalSocket.

 The code I'm using to launch the threads in the server is something like
 this

 void LocalServer::newClientConnectionSlot()
 {
 QLocalSocket *localSocket = localServer-nextPendingConnection();
if (localSocket) {
 QThread *thread= new QThread;
 MyWorker *worker = new MyWorker();
 worker -moveToThread(thread);

 thread-start();

localSocket-setParent(NULL);// remove local server parent
 in order to properly use the socket on another thread
localSocket-moveToThread(thread);
rpcPingReplyer-setLocalSocket(localSocket);
 rpcPingReplyer-startPingReplying();
}
 }

 Each thread is using its own localSocket to communicate with the client.

 My question is, is it safe to use different instances of QLocalSocket
 from different threads without guarding those sockets? The documentation
 does not report QLocalSocket is reentrant. What does it imply? Should I
 guard all QLocalSocket instances with a global mutex before using them?

 Thanks in advance for your hints!
 Calogero
 Sorry, the example I previously wrote was not fully correct.
 Here is a better one

 void LocalServer::newClientConnectionSlot()
 {
QLocalSocket *localSocket = localServer-nextPendingConnection();
if (localSocket) {
   QThread *thread= new QThread;
   MyWorker *worker = new MyWorker();
   worker-moveToThread(thread);

   thread-start();

   // move local socket to thread
   localSocket-setParent(NULL);
   localSocket-moveToThread(thread);
   worker-setLocalSocket(localSocket);

   // start communicating with client
   worker-startCommunicate();
}
 }

I think the problem you have is in the last line of the code. This 
should probably be

connect(thread, SIGNAL(started()), worker, SLOT(startCommunicate()));

The difference is in which thread you are running the startCommunicate() 
function. In your code, it's running in the creating thread, but when 
connecting to started() it is in the created thread. Which changes the 
thread affinity of any QObject instances created in the function.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Poor QMethod::invoke performance across threads on i.MX53

2015-05-27 Thread Bo Thorsen
Den 27-05-2015 kl. 23:16 skrev Matthew Woehlke:
 On 2015-05-27 16:41, Thiago Macieira wrote:
 On Wednesday 27 May 2015 15:02:36 Matthew Woehlke wrote:
 On 2015-05-18 03:46, Thiago Macieira wrote:
 On Thursday 14 May 2015 18:18:52 Robert Daniels wrote:
  moveToThread(this);

 This is wrong. Never do moveToThread(this), since it's very difficult to
 then destroy the QThread object. This is unrelated to the problem and
 it's probably only for simplicity of your testcase.

 Sort of OT, but... why? If the object in question is destroyed by the
 same thread that created it, after the thread that the object
 represents has terminated cleanly, what is the problem?

 The problem is a QThread living inside the thread that it started.

 You can't destroy that object inside that thread because the QThread
 destructor will wait() until the thread exits. And the thread can't exit 
 until
 the destructor has returned. That's a deadlock.

 Right. An example probably helps. What's wrong with this approach?

class MyThread : public QThread { ... } // has moveToThread(this)

int main()
{
  auto* t = new MyThread;
  t.start();
  // ...
  t.wait();
  delete t; // QThread deleted from main thread, not itself
}

 The QThread is memory-managed from a thread other than itself. It's just
 that the thread affinity is circular. Note that I am *NOT* trying to
 deleteLater the QObject! (Because, yes, that would be horrible! And for
 that matter, would leak, since in my usage, the thread has exited before
 I try to delete it.)

 Anyway, a more accurate depiction of my case is:

class MyThread : public QObject
{
  QThread self;
  MyThread() { moveToThread(self); }
}

 ...where again, it is assumed that MyThread is deleted from a thread
 other than MyThread::self. Is this approach broken? (I think no? It
 seems similar to the alternate approach you gave.)

There are a lot of problems with this. Thiago already gave you a couple 
of them. Here are two more:

The finished() signal on QThread - which thread do you expect this to 
run in? And which thread would you expect a slot connected to it to run in?

What about objects with your thread as parent? Those will all be deleted 
by the wrong thread. If you delete them all before the thread itself is 
deleted, then you can only have a single reason left for 
moveToThread(this): Signals and slots on the QThread. Refactor your code 
and create another object that does all the work you put in the run instead.

QThread is an object that you should think of as living between the two 
threads. The object itself is running in the creating thread, anything 
in run() and objects moved to this thread is in the created thread. The 
signals it emits have clearly defined threads they are emitted in - 
finished() in the creating thread, started() in the created etc.

It's not that you can't create code with your way that will work. It's 
more that it will be impossible for anyone schooled in the proper way 
of thinking to know what's going on. You will create weird bugs that are 
very hard to fix with this approach.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Call for Papers to Qt World Summit now open

2015-05-10 Thread Bo Thorsen
Den 05-05-2015 kl. 09:24 skrev Kojo Tero:
 Hello!

 The call for papers to the Qt World Summit has been opened.

 We welcome you to share your insight, experience and inspiration at our
 12th annual Qt event.

 For details on the themes and instructions for submitting your
 abstracts, please see this blog post:

 http://blog.qt.io/blog/2015/04/30/experts-wanted-call-for-papers-qt-world-summit-2015/

The deadline for submission is missing, isn't it?

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt Desktop on Windows 10 TP

2015-05-10 Thread Bo Thorsen
Den 10-05-2015 kl. 06:42 skrev Robert Iakobashvili:
 Have anybody tested Qt Desktop Applications for Windows
 on Windows 10 TP when Qt is:

 1. Qt-4.8 (4.8.5, 4.8.6);
 2. Qt-5.2
 3. Qt-5.3

 I see there is a bug fixed in 5.4.1.

 What will be user experience when using older Qt-versions?
 Thanks.

If you write proper Qt applications, they will continue to work without 
any problems. That has been the case for all new Windows releases over 
the years.

It might look outdated, but even this seems to happen less and less over 
the last revisions of Windows.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QtSql database insertion issues...

2015-04-24 Thread Bo Thorsen
Karl, don't worry. the SQL module is not going anywhere. Jason is right 
in the sense that it's considered done. He's wrong in thinking this has 
anything to do with NoSQL.

NoSQL isn't emerging as a the SQL killer that NoSQL guys believe it is. 
Instead it's a different tool that has other use patterns.

On 04/23/2015 04:45 PM, Karl Ruetz wrote:
 I sincerely hope you are wrong; at least for the next several years.
   (Like 10 years.)
 Staying on the bleeding edge is simply not an option for many of us that
 are simply Qt users (not developers).  It took us years to update to Qt
 5 because they killed QFTP without a fully functional replacement.  QNAM
 does not have all the functionality for FTP that QFTP did and building
 QFTP with the newest versions of Qt is problematic at best.  Killing the
 SQL module would probably mean the end of Qt for our organization.

 I realize that cutting edge stuff is more fun.  But we live in a world
 where our customers keep old equipment around for decades and they are
 willing to pay to keep it running.  So we still have to support Windows
 NT 4 and RHEL 4 even though it’s not as fun as working with the latest
 and greatest.  So please, I beg of you, do not remove any functionality
 without a complete, viable, fully functional replacement.

 Karl

 On Apr 23, 2015, at 9:35 AM, Jason H jh...@gmx.com
 mailto:jh...@gmx.com wrote:

 Very true. If you need something like that to be agnostic, then you
 need to use a query builder or ORM.
 But it's not like Qt is very agnostic. Pragmatically speaking, the
 lack of constistent binding across of drivers kills it right out of
 the gate.
 In days like this, where NoSQL is an emerging trend I can't see
 anything really happening at the SQL module anymore.


Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] qsort() Obsolete?

2015-04-17 Thread Bo Thorsen

On 04/17/2015 12:12 PM, Berkay Elbir wrote:

Hello All,

I want to ask a question to you to be certain. Is void qsort() function
obsolete? Should we use std::sort instead of this function? Because I
have a priority list and need to sort it.


Slightly off-topic: Don't implement a priority queue this way. Unless 
you have a system where you get a bunch of those and can sort them once, 
and handle all of them. If this isn't the case, you are going to have 
inserts and removes mixed. Then you will continually sort something 
that's already sorted.


I have an old implementation of a priority queue you can use instead. 
It's an implementation of a binary heap algorithm. It's optimized for 
the case where there are just a few items in the queue and very rarely 
it will get a burst of more. If your case doesn't match this, you could 
probably remove the resize to minimum. You can instantiate it with 
anything that implements operator.


I hope it helps.

Bo Thorsen,
Director, Viking Software.

--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
#ifndef VSTOOLS_PRIORITYQUEUE_H
#define VSTOOLS_PRIORITYQUEUE_H

#include QList

class PriorityQueueTest;

namespace VSTools {

template typename T class PriorityQueue {
public:
enum { MinimumSpace = 8 };

PriorityQueue() : mReserved(0), mCount(0), mEntries(0) {
}

~PriorityQueue() {
delete[] mEntries;
}

void enqueue(T item) {
if (mCount  2  mReserved != MinimumSpace) {
// Our list was (almost) empty, resize it to 8 so we have some room. This also prunes the list if it used to be bigger
resize(MinimumSpace);
} else if (mCount == mReserved) {
// We need more space
resize(mReserved * 4);
}

// Insert this at the end of the tree
int i = mCount;
int parent = (i - 1) / 2;
mEntries[mCount++] = item;

// Test that the tree is still in order
while (parent = 0  i  0  mEntries[i]  mEntries[parent]) {
swap(parent, i);

// Go up the tree and retest
i = parent;
parent = (i - 1) / 2;
}
}

T dequeue() {
Q_ASSERT(!isEmpty());

if (mCount == 1) {
// Small optimization
mCount = 0;
return mEntries[0];
}

// Take the first and move the last to the top
T item = mEntries[0];
mEntries[0] = mEntries[--mCount];

// Sink the top down
int i = 0;
while (true) {
int swapWith = 2 * i + 1;

if (swapWith = mCount) {
// We're at the end
break;
}

if (swapWith  mCount - 1  mEntries[swapWith + 1]  mEntries[swapWith]) {
// Use the right entry instead
++swapWith;
}

if (mEntries[swapWith]  mEntries[i]) {
swap(swapWith, i);
i = swapWith;
} else {
// Done, we found the right place in the tree
break;
}
}
return item;
}

const T peek() const {
Q_ASSERT(!isEmpty());
return mEntries[0];
}

inline int count() const { return mCount; }

/// Returns true, if this queue is empty
inline bool isEmpty() const { return mCount == 0; }

void clear() {
mCount = 0;
if (mReserved  MinimumSpace) {
resize(MinimumSpace);
}
}

private:
Q_DISABLE_COPY(PriorityQueue)

void resize(unsigned int reserved) {
mReserved = reserved;
T* oldEntries = mEntries;
mEntries = new T[reserved];

// Copy over the old entries
for (int i=0; imCount; ++i) {
mEntries[i] = oldEntries[i];
}

delete[] oldEntries;
}

inline void swap(int i, int j) {
T temp = mEntries[i];
mEntries[i] = mEntries[j];
mEntries[j] = temp;
}

int mReserved;
int mCount;
T* mEntries;
};

}

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


Re: [Interest] sqlite

2015-04-17 Thread Bo Thorsen
On 04/17/2015 02:36 PM, André Somers wrote:
 Bo Thorsen schreef op 17-4-2015 om 14:24:
 On 04/17/2015 02:10 PM, André Somers wrote:
 Bo Thorsen schreef op 17-4-2015 om 13:48:
 On 04/17/2015 10:25 AM, Graham Labdon wrote:
 Hi
 My application makes use of an sqlite database that needs to be shared 
 amongst
 multiple instantiations of the application.
 Can  anyone please suggest how I can implement this such that if one
 instantiation of the application updates the database then any other
 instantiations that are running get notified.
 You can't do this. There is no mechanism in sqlite to notify other
 applications that something has changed. You are going to have to
 implement an IPC system for this.

 In fact: don't do that at all. Don't use sqlite for simultanious access
 by several processes. We did (against recommendation of the engineers,
 management forced a 'quick fix' to get a feature in), and we're still
 sorry for it. You'll end up in hack-upon-hack to make it sort-of-work,
 but it is no end of pain and sooner or later will end up in data
 corruption in your data base.
 This contradicts the info on the sqlite website. They claim that it's
 possible to do exactly this. Interesting that you disagree.
 In practice, we found that it results in problems in practise, even if
 it may work in theory. Perhaps it is due to the actual sqlite, perhaps
 it is due to the fact that it really is just a file and it is the
 (networked) file access that is to blame in the end in our case, but the
 problems are real.

According to the same documentation, it does not work if the file is on 
a networked file system. So if the OP use a local file system only, then 
it might still work.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] sqlite

2015-04-17 Thread Bo Thorsen
On 04/17/2015 10:25 AM, Graham Labdon wrote:
 Hi
 My application makes use of an sqlite database that needs to be shared amongst
 multiple instantiations of the application.
 Can  anyone please suggest how I can implement this such that if one
 instantiation of the application updates the database then any other
 instantiations that are running get notified.

You can't do this. There is no mechanism in sqlite to notify other 
applications that something has changed. You are going to have to 
implement an IPC system for this.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] sqlite

2015-04-17 Thread Bo Thorsen
On 04/17/2015 02:10 PM, André Somers wrote:
 Bo Thorsen schreef op 17-4-2015 om 13:48:
 On 04/17/2015 10:25 AM, Graham Labdon wrote:
 Hi
 My application makes use of an sqlite database that needs to be shared 
 amongst
 multiple instantiations of the application.
 Can  anyone please suggest how I can implement this such that if one
 instantiation of the application updates the database then any other
 instantiations that are running get notified.
 You can't do this. There is no mechanism in sqlite to notify other
 applications that something has changed. You are going to have to
 implement an IPC system for this.


 In fact: don't do that at all. Don't use sqlite for simultanious access
 by several processes. We did (against recommendation of the engineers,
 management forced a 'quick fix' to get a feature in), and we're still
 sorry for it. You'll end up in hack-upon-hack to make it sort-of-work,
 but it is no end of pain and sooner or later will end up in data
 corruption in your data base.

This contradicts the info on the sqlite website. They claim that it's 
possible to do exactly this. Interesting that you disagree.

 Sqlite is very nice as a small, local,
 simple database, but it is no replacement for running a real database
 server. If you need concurrent access by multiple processes, use a
 database that is built for that kind of thing. MySql, PostgreSql, whatever.

And in that case the OP is back to the original question and answer.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] How to avoid QProcess polling

2015-04-16 Thread Bo Thorsen
On 04/08/2015 09:21 AM, Shantanu Tushar wrote:
 Hi,

 Lets say I launch an external application on Windows using this code-

 QProcess p;
 p.start(C:\\Windows\\notepad.exe);

 Once I run the app and notepad (in this example) is launched, there is
 constant activity happening in my main process (which I found using
 http://technet.microsoft.com/en-in/sysinternals/bb896653.aspx).

 I used some profiling tools and found that its because of a QTimer that
 QProcess starts here-

  if (threadData-hasEventDispatcher()) {
  processFinishedNotifier = new QWinEventNotifier(pid-hProcess, q);
  QObject::connect(processFinishedNotifier,
 SIGNAL(activated(HANDLE)), q, SLOT(_q_processDied()));
  processFinishedNotifier-setEnabled(true);
  notifier = new QTimer(q);
  QObject::connect(notifier, SIGNAL(timeout()), q,
 SLOT(_q_notified()));
  notifier-start(NOTIFYTIMEOUT);
  }

 (from
 http://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/io/qprocess_win.cpp#n542)

 Right now I hack around this by doing this-

 QThread t;
 QProcess p;
 p.moveToThread(t);
 p.start(C:\\Windows\\notepad.exe);

 which basically causes the hasEventDispatcher() if condition to false
 and no polling happens. However, this generates warnings because the
 QProcess attempts to generate children. Further, I lose the ability to
 read stdout from the process.

 Is there a cleaner way to disable the polling? Or at least make it less
 frequent? Just in case you're wondering, this is important because our
 users are freaks about CPU utilization and they don't want to see 0%
 CPU usage when the app is idle from their perspective.

Warning! I have no idea if this is evil or not. Try and google the 
consequences if you want to try it out.

If you really want to get rid of this, you can easily do it:

qDeleteAll(process-findChildrenQTimer());

Careful though! I don't know if stdout or stderr might fill up here, or 
what might happen inside. This is where you have to figure it out.

You can redirect output to to a file and read it later.

You can also use the findChildren call to find the timer and set the 
timer to something slower.

All this said, I think you should consider if it's really a problem that 
a couple of timers fire in your main application.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QTreeWidget with fixed or min row height

2015-03-16 Thread Bo Thorsen
Den 16-03-2015 kl. 17:47 skrev Duane:
 I'm trying to set up a tree widget where I can resize the column width
 to content but maintain a fixed row height.

 I have a custom delegate which I use to paint cell borders and I've
 added an overload to QSizeHint for this. I've also tried just setting
 the size hint but in either case column height works but the width
 doesn't size properly.

 Is there a way to achieve setting the tree's resize mode to resize to
 contents but also setting the height?

Hi Duane,

You can emit the dataChanged for the cell and change the SizeHintRole.

The problem with this is that the model now needs UI information so it 
gets tightly coupled with a single view widget, but that's a known 
design issue with those classes. If you need this model to be visible 
for multiple views, you have to use a proxy model to set the size hint.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Bounties?

2015-03-13 Thread Bo Thorsen
Den 13-03-2015 kl. 23:45 skrev Bernhard:
 I think it'll be a lot easier to convince the Qt Project JIRA admins to
 hack on a
 bounty system if there's some precedence that the system actually works :)

 Sounds like a chicken-and-egg problem... I am pretty sure this will not work
 without seamless JIRA integration.

Bounty systems can't work, no matter how good an idea it might seem to 
be. Here's just a few of the reasons why:

* Suppose you create a bounty. A year later someone fixes the bug in the 
latest version. How is payment guaranteed? Do you have to pay a middle 
man immediately? You won't do that because the bounty might never be 
claimed, but if you don't, how can the fixer be certain he will get the 
bounty? This only grows worse, if there are multiple payees to a bounty 
(which is usually how people think this might work).

* You created the bounty for Qt version 5.1.0. But that's a dead branch 
and it's impossible to get the fix in upstream. How do you handle if 
someone fixes the bug in a later version?

* How do you handle bugs that disappear? As rare as this may be, 
sometimes bugs actually do disappear, for example when they are a 
symptom of an underlying but seemingly different problem.

* Who handles when you disagree that the bug is fixed?

It's a HUGE piece of work to do this in any way that's not just comments 
in JIRA, and it's a legal nightmare. And it just doesn't work. We tried 
this when I worked for Monty Program (the company that created MariaDB, 
run by the guy that wrote MySQL). I don't know how long after I left 
that they kept trying to do it, but AFAIK they never once actually had a 
bounty that was paid.

Why do you think those bounty sites are deserted?

If you think you're the one who will make an idea that have been proven 
impossible to realize, go right ahead. This is only my opinion, and I'm 
in no position to stop anyone doing it. But IMHO this should not be done 
within the Qt ecosystem.

When you need to have a bug fixed, pay someone to do it.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Is there a command line call to qmake to test the bit width?

2015-03-12 Thread Bo Thorsen
Den 04-03-2015 kl. 19:39 skrev Scott Aron Bloom:
 -Original Message-
 From: interest-bounces+scott.bloom=onshorecs@qt-project.org 
 [mailto:interest-bounces+scott.bloom=onshorecs@qt-project.org] On Behalf 
 Of Thiago Macieira
 Sent: Wednesday, March 04, 2015 9:44 AM
 To: interest@qt-project.org
 Subject: Re: [Interest] Is there a command line call to qmake to test the bit 
 width?

 On Wednesday 04 March 2015 17:15:45 Scott Aron Bloom wrote:
 By then its too late.. I want the shell script that calls the make
 system to fail, saying you have the qmake setup wrong...
 Why would it be wrong? If qmake is installed, it's been installed correctly 
 right? :-)

 And what is the issue you're trying to figure out?

 Its really only an issue when linking, since it will pick up the wrong
 libraries.
 No, it won't. The libraries come from the linker.

 --

 No.  Maybe Im not explaining myself correctly.  Since this was purely a 
 question on qmake, or if there was anyway to look at a Qt install an see what 
 bit width it was built against.

 However here are all the gory details.

 On a single system, I have 2 versions of the SAME Qt installed, 64 bit and 32 
 bit, both installed correctly.

 Visual Studio has two compilers, one for 64 and one for 32.  That said, when 
 I used to release our tool for linux 32, we had a similar issue..

 The developers setup build script, requires the cl to be pointing to the 
 correct cl, ie, that you have run vsvars before you run cmake (which then has 
 the dependency on qmake)

 If I am trying to build the 64 bit system, but my shell is pointing to the 32 
 bit compiler, but the 64 bit Qt system, it will most likely compile just 
 fine, but it will not link correctly.

 Im trying to put the logic into my CMake system, to query the version of 
 qmake to determine, if the user has selected the appropriate Visual Studio 
 and Qt version.

 And yes, I would have had to do the same thing (though we dropped 32 bit 
 linux support, and devs never really worked on it) to confirm they were 
 building a 32 bit version of the tool against  a 32 bit version of Qt (or 
 vice versa)

Sounds like you should do a simple cmake test case where you build a 
small dummy application and link it. This should give you the answer 
immediately.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


Re: [Interest] Does removing 'private slots' from .h files have any advantages? Disadvantages?

2015-03-12 Thread Bo Thorsen
Den 08-03-2015 kl. 11:58 skrev Guido Seifert:
 I am just curious. In one of my old projects I replaced all SIGNAL/SLOT 
 connections with the newer function pointer api.
 In theory I now could remove all the 'public/protected/private slot' markers 
 from my .h files. Now I am wondering, if this
 is only cosmetic, or does it have any advantages/disadvantages? Faster 
 compile time? Smaller executables?

Hi Guido,

I think the main disadvantage in this is that it would surprise Qt 
developers. There is knowledge in you writing slots in the .h file, 
just like there is in using emit.

Personally, I don't use this feature much. The parts of the new connect 
that I use is the new connect syntax for compile time checked connects 
and lambdas.

Instead of considering whether I should write slot in the .h file, I 
try to make the public parts of my class smaller using the new 
approaches. This gives me fewer changes to the header files as I work 
with them, which brings down recompile time.

One example of a useful conversion is in network code. If you have a 
class that sends multiple http requests, in Qt 4 you might have a 
private slot that uses sender(). With the lambda approach, you get rid 
of a private slot and remove the need for the slightly obnoxious use of 
sender(). IMO changes like this gives you real advantages instead of 
just cosmetic changes.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


Re: [Interest] Bounties?

2015-03-12 Thread Bo Thorsen
Den 11-03-2015 kl. 21:36 skrev Bernhard:
 I did not say that we *cannot* continue with Qt. What I say is that it gets
 more painful and difficult.
 For our current projects there are no options anyway.

 But there may be projects in the future at other companies where I will get
 asked again What would do you think about Qt?. And I will need to say:
 Years ago I had the impression that quantity and quality are at an optimal
 balance but this changed in my opinion. What a pity. However if enterprise
 support actually improves this then at least for mid-size and bigger
 companies this not a problem.

 I started using Qt with 4.0.0 and pretty much fell in love with it... seems
 my cutie is letting itself go ;-)

I know how you feel. And I started with 0.4 :)

However, since 5.3 it's improved a lot. QML is still buggy to a point 
where it's quality is way lower than the rest of the system. But Qt 
itself (for widget based applications) in 5.3 and 5.4 is IMHO almost as 
good as 4.8. IIRC, I think it was around version 4.3 or 4.4 before I 
started to really push Qt 4 to my customers. Qt 5 is following in much 
the same curve, although the changes from 4 to 5 were less disruptive 
than from 3 to 4 so the comparison might not be fair.

I think Qt Company is doing a good job of improving the 5 series one 
release after another.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Bounties?

2015-03-12 Thread Bo Thorsen
Den 12-03-2015 kl. 10:15 skrev m...@rpzdesign.com:
 Bo:

 I am quite shocked.

 Is 5.4.1 QML so buggy as to be un-usable for mobile development?

No, it's not unusable. I said the quality is way lower, that's certainly 
not the same as unusable. In the Qt community we're spoiled with quality 
that's so far above the rest of what's out there, so when QML based 
applications are only as good as the rest, then it's bad compared to the 
rest of Qt.

 Is the 5.4.1 mysql support so unstable as to be un-usable?

?? I have used this for several customer projects without any problems. 
Why would you ask this?

 Are you saying that widgets is STILL the way to go for mobile in 5.4.x+?

No. For mobile I would only use QML. For embedded applications, it's a 
harder question and depends on the target application.

I'm right now working on a desktop application implemented in QML. To 
implement this in QML was a mistake that's now impossible to correct. It 
would have been better with widgets.

The only part of QML (or Qt) that's IMHO unusable is the desktop components.

 Does Viking software survive in 5.4.x + only via Enterprise support?

No. Viking Software is a Qt consulting company. I have 18 years of Qt 
coding experience. Support is not required :)

 Are the reported bugs really not getting fixed in any timely fashion?

Some are, some are not. That's the way it is with open source projects. 
If you need a bug fixed, get support from Qt Company or fix it yourself 
or hire one of us consultants to do it.

Bo.


 On 3/12/2015 1:36 AM, Bo Thorsen wrote:
 Den 11-03-2015 kl. 21:36 skrev Bernhard:
 I did not say that we *cannot* continue with Qt. What I say is that it gets
 more painful and difficult.
 For our current projects there are no options anyway.

 But there may be projects in the future at other companies where I will get
 asked again What would do you think about Qt?. And I will need to say:
 Years ago I had the impression that quantity and quality are at an optimal
 balance but this changed in my opinion. What a pity. However if enterprise
 support actually improves this then at least for mid-size and bigger
 companies this not a problem.

 I started using Qt with 4.0.0 and pretty much fell in love with it... seems
 my cutie is letting itself go ;-)

 I know how you feel. And I started with 0.4 :)

 However, since 5.3 it's improved a lot. QML is still buggy to a point
 where it's quality is way lower than the rest of the system. But Qt
 itself (for widget based applications) in 5.3 and 5.4 is IMHO almost as
 good as 4.8. IIRC, I think it was around version 4.3 or 4.4 before I
 started to really push Qt 4 to my customers. Qt 5 is following in much
 the same curve, although the changes from 4 to 5 were less disruptive
 than from 3 to 4 so the comparison might not be fair.

 I think Qt Company is doing a good job of improving the 5 series one
 release after another.

 Bo Thorsen,
 Director, Viking Software.

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


Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Bounties?

2015-03-12 Thread Bo Thorsen
Den 12-03-2015 kl. 14:57 skrev maitai:
 If an app needs to be qml for mobile and qwidgets for PCs, then the
 whole concept of portability is broken.

Please don't try and claim that my concepts are broken :) I have 
multiple applications for multiple customers. They are not related in 
any way.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Printing not working on Windows

2015-03-11 Thread Bo Thorsen
Den 04-03-2015 kl. 02:48 skrev Scott Aron Bloom:

 In my migration from Qt4 to Qt5, some of the machines the new 
 application is installed on, the print functionality is not working, 
 the print button is live and is connected fine.

 However, on some machines, the print dialog doesn’t work. 
 Qt5PrintSupport.dll is packaged, Im just thinking there is some 
 dynamically loaded dynamically bound dll, that it cant (because Im not 
 including it in the installer) find causing the dialog to not work.

 Any thoughts/ideas?


Hi Scott,

Just a general comment for this. Whenever I have a problem where 
something isn't working in the installed version, the first thing I do 
is to copy the entire plugins tree from Qt to the installed location. 
This immediately tells me if I'm on the right path or if the problem is 
somewhere else.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


Re: [Interest] To rpath or not when building Qt

2015-03-11 Thread Bo Thorsen
Den 10-03-2015 kl. 20:07 skrev Scott Aron Bloom:

 When building Qt for distribution via LGPL of a closed source product 
 using shared libraries.

 What is the best method to make sure the plugins pickup the Qt 
 libraries you are shipping?


In this case you mean this as a help to the user, right? That he can 
just start the application and then it works.

The usual approach on unix based systems is to ship a script that runs 
the executable with the proper library path set. This way you can 
support multiple install locations which rpath can't do.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


Re: [Interest] Bounties?

2015-03-11 Thread Bo Thorsen
Den 11-03-2015 kl. 11:37 skrev Bernhard:
 Hi!

 We are a very small startup company (having part time Qt developers only).
 We are experiencing that non-fatal bugs as well as suggestions pile up
 infinitely or simply are ignored or don't have caretaker at all. Votes seem
 to be ignored most time too and personal severity does not matter anyway.
 Unfortunately we cannot afford a lot of time or money to fix found issues by
 our self (or pay someone to do this). This situation makes Qt development
 more and more difficult for us.

 So here are two questions:
 1. Is there some kind of bounty system/site/service or something equivalent
 to it? Especially for issues that affect more than one developer/company
 this could be a very effective and affordable way to get rid of issues
 without burden a single developer/company with the costs.
 2. Are there any special support agreements for small companies / startups /
 part-time developers / hobbyists that help getting issues fixed without big
 costs?

Hi Bernhard,

The bounties approach has been tried often, and it sounds like a good 
idea. I also worked for a year at the company behind MariaDB which tried 
to do this on a larger scale. But so far I've only heard about failures 
with it.

One thing that you can do which is quite cheap is to improve the bug 
reports. Make sure there's a small self contained piece of example code 
that shows the problem. Focus on the small - a 100K lines of code 
project that shows the problem is useless in bug reports). By improving 
the bugs and perhaps even posting some info on where the problem might 
be in Qt, you increase the chance that one of the Qt developers will 
pick up the bug. Also, the easier the problem is to spot in the example 
application, the more important it might look, so again, you increase 
the chances.

You could also assign one of your own developers to fix the problem. Qt 
isn't closed, after all.

Failing this, there are three things you can do, if you do want to throw 
a bit of money behind it:

1) Let an experienced Qt guy look at the code that hit the problems and 
see if it's possible to work around it. Sometimes solutions are best 
done by approaching the problem from a different direction.

2) Implement hacks (aka more involved workarounds) by looking at the Qt 
source code. For example, if you need a combo box that works slightly 
different, you might be able to create a completely new widget that just 
uses the style to paint your widget like a combobox. Finding options 
like those are difficult and requires a lot of experience.

3) Hire Qt Company or one of us Qt consulting companies to implement a 
Qt fix and work on getting it upstream.

When looking at the cost of this, 1 or 2 is cheaper, 3 might be a longer 
term fix. Nr 1 might be done by your own guys with the help of this 
mailing list.

I hope this helps,

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


Re: [Interest] sha256 checksums for Qt downloads

2015-02-19 Thread Bo Thorsen
On 02/19/2015 02:36 PM, Jérôme Pinguet wrote:
 Hello!

 Would it be possible to add sha256 (and/or sha512) checksums to the Qt
 4.8.6 download page [1]?

 md5 checksums are easily forged in a few days with a couple of GPUs. In
 a post-Snowden era, to avoid security issues with downloads on a page
 that is not https by default, using sha2 (sha256 for instance) is necessary.

 Other security enhancements suggested:

 * make https default for download pages
 * sign checksums files (md5sums-4.8.6 and the future sha256sums-4.8.6)
 file with a well known Qt developper's GPG key

 Thank you for helping all of us improve security and fight malware
 through the use of up-to-date and secure hashing algorithms! :-)

 [1] http://download.qt.io/archive/qt/4.8/4.8.6/

There's a very clear rule in 4.8: No new features are allowed. It's 
pretty much only security fixes that will find it's way to this. Perhaps 
some bug fixes as well.

So no, you won't get this for a 4.8 based application.

Your options are to upgrade Qt to 5.x (which you probably chose not to 
for some reason) or to implement it yourself.

If you need this for a 4.8 based application, you can just create your 
own Qt patch and build Qt yourself with it. It shouldn't be difficult to 
port the code from the 5.x sources to 4.8.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Can QML do this animation?

2015-02-18 Thread Bo Thorsen
On 02/18/2015 11:44 AM, Mark Gaiser wrote:
 On Wed, Feb 18, 2015 at 1:18 AM, Jason H jh...@gmx.com
 mailto:jh...@gmx.com wrote:

 Yes, I think 80% of it is 100% do-able.
 Rotation defined by bytes receiced, with bounce easing.
 The only issue  is the drain animation. I'd probably use   Canvas
 and mathmatically define the position of a set of control points as
 a function of time. Feed those to a path, and you've got all the
 makings of a drain effect.

 I actually don't mind the drain animation, it's nice, but i never
 imagine a progressbar to drain in that way :)
 But i do like to - try and - make a progressbar in the same fashion with
 a tooltip floating above it. Guess it's time to play with QML and see
 how far i can get with this.

You were worried about synchronizing the end of the progressbar with the 
location of the floater (hmm, that's probably a bad word for it) above 
it, right?

To fix this, create a property that's used by both the progressbar and 
the sign.

Item {
   property int currentX: progress / 100 * progressWidth

   Behaviour on currentX { ... }
}

If you want to rotate the sign but not the text, then encapsulate the 
item twice:

Item {
   id: floater

   Item { id: signPart: ... }
   Item { id: textPart; ... }
}

Then you can rotate the signPart without rotating the text.

Doing stuff like this is where QML is *fantastic*, and it's great fun to 
figure out how to do it.

Be careful to encapsulate everything in Items, or you will regret it 
later. You can have a look here for a bit of inspiration (shameless 
plug, it's my own Qt blog): http://www.vikingsoft.eu/blog/?p=173

Have fun :)

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Font problem

2015-02-17 Thread Bo Thorsen
Den 09-02-2015 kl. 22:31 skrev henning.carl...@rosenkildeglas.dk:
 I have recently ported a QT4 on SUSELinux project into a QT5 Ubuntu.

 Most things are well but Boss complains that the text in fields and
 buttons are now exploding the frames.

 The font is newer set in the project, only sizes is set on widgets, so
 the default font is used.

 Investigating in the old project printing out the font() for a fields,
 reviles that “DejaVu Sans” is the font used.

 Even though I can’t find the font on the embedded disk running the system.

 On the QT5 the same font is still used but now being about 10-12% wider.

 Has the default font for QT been changed from QT4 to QT5 and how can I
 get hold on the original font used as default for QT4.

It sounds like you just need to change the font. As Lisandro mentioned, 
there are different fonts installed with different Linux distros, so 
this isn't an easy task.

If you really want to do this in a way that ensures a slim font, you 
have to write code to choose the proper font. Something like a list of 
font names to check, and a set of strings where you test the width of 
the printed string with each font until you find an acceptable font.

I hope this helps,

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Failed to make moc for cpp source file.

2015-02-10 Thread Bo Thorsen
Den 10-02-2015 kl. 10:30 skrev Igor Mironchik:
 Hi. I ran into a problem.

 When building project for Android target, build doesn't make moc for a cpp
 file and compilation failed.

 In that cpp I have Q_OBJECT and #include messagebox.moc

 In Makefile generated I have:

 mocables: compiler_moc_header_make_all compiler_moc_source_make_all

 compiler_moc_source_make_all: .moc\messagebox.moc

 But I got:

 ..\..\..\Mobile\QtMWidgets\src\messagebox.cpp:622:26: fatal error:
 messagebox.moc: No such file or directory
#include messagebox.moc
 ^
 compilation terminated.

Hi Igor,

I was just working on a fix for a qmake bug that involves exactly this 
case. In my bug there was a place in the code that said foobar and 
the workaround is to do foo bar (notice the space between the two 
strings). It's bug 17533 in the Qt bugtracker.

I guess you hit a bug related this.

You can check if you are hit by a similar bug. Check the Makefile and 
look for the rule to build messagebox.o - it has to list messagebox.moc 
at the end of the list of dependency files. If it's not there, your moc 
file won't be built.

Unfortunately I can't tell you how to work around it, if it is the same 
problem, because there might be other ways to trigger it. The way I 
would work around this is to remove almost all the code in the file and 
see if you can get the moc file to show up as a dependency and then 
re-add the code until it disappears from the list. Then you can find the 
place where your code stops the moc dependency check from working and 
try to find a way to work around it.

For reference, my Makefile.Debug on Windows has this in the file:

### Compile

debug\main.obj: main.cpp ..\build-5.4\include\QtCore\QtCore \
 ..\build-5.4\include\QtCore\QtCoreDepends \
 debug\main.moc

I just saw your second message on this, and you don't get the Makefile. 
So I don't know if this is helpful at all. But the dependency check in 
qmake should be the same for your project generator, so it could be.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] New Development Environment

2015-02-07 Thread Bo Thorsen
Den 07-02-2015 kl. 20:09 skrev Karl Ruetz:
 Our company is about to start the process of altering our Qt development 
 environment.
 I’ve noticed that it seems most of the Trolls (if I can still use that term) 
 are using Ubuntu.
 I’d like to save a little of trial and error and find out what version of 
 Ubuntu 64-bit would be best to use if we plan to setup Qt and QtCreator from 
 the latest Enterprise versions available.  Any inputs would be welcome.

Hi Karl,

Don't choose your Linux version from this. Qt works well on all the 
newer Linux versions. Ubuntu is fine, but openSUSE, RedHat, Mint or any 
of the others are just as good.

If you choose one of the major versions, Qt won't give you any problems. 
And it probably won't on more esoteric versions.

I would choose this based more on the toolchain available on the 
platform. Up to date gcc and gdb, for example. For example, in Ubuntu I 
just got hit by a really bad gdb bug that made gdb unusable for large 
projects.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Installing on a headless server

2015-02-05 Thread Bo Thorsen
On 02/05/2015 09:04 PM, Jason H wrote:
 I need to install Qt (Enterprise) on a headless server (CentOS) (I use 
 -platform minimal) . There is only the GUI installer.

 How can I get Qt installed on the server so I can generate reports?

 --OR--

 How can I build my package for distribution (incl deps)  to the headless 
 server?

Forget the binary package, it's impossible for you to use in this case.

Take the centos Qt source package(s?), replace the opensource sources 
with the enterprise sources in the package, rename to qt-enterprise or 
something, build the package.

That will give you a set of native centos packages with dependency info 
in them and an easy upgrade path later. It also allows you to easily 
distribute patches, if you need them.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QSqlDatabase

2015-02-04 Thread Bo Thorsen
Den 04-02-2015 kl. 15:18 skrev alexander golks:
 Am Wed, 4 Feb 2015 15:01:50 +0100
 schrieb Till Oliver Knoll till.oliver.kn...@gmail.com:




 ...
 QSqlDatabase db = QSqlDatabase::addDatabase(QSQLITE);
 ...
 bool ok = db.open();

 When I run this ok is always true, no matter what arguments are passed.
 I am not experienced with SQLITE, but is it possible that each time a new DB 
 instance (file) is created, if no such instance exists yet? Hence the 
 connection alway succeeds?

 or perhaps because sqlite has no notion of usernames, passwords, et al? just 
 the filename matters.

That's exactly what happens. sqlite is a simple file. You have whatever 
normal file modification rights your current user have on it.

If that's not what you need, you can't use sqlite.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


Re: [Interest] QtConcurrent and event-driven objects

2015-01-27 Thread Bo Thorsen
On 01/26/2015 11:56 AM, Dmitriy Purgin wrote:
 Hi,

 I'm using Qt to power an application server with multithreaded TCP
 listener and maintenence tasks running in separate threads. The TCP
 listener runs in main thread and spawns a separate thread to handle
 socket operation. The socket is being created when the thread is running
 using a socket descriptor passed from the TCP listener. The maintenance
 threads hold a timer only and run on timer shot to query DB and do stuff
 (doesn't really matter).

 The thing is, I have always used it like this:

 // [L1] Listing 1
 // this simplified sample code neglects cleanup and possible memory leaks
 class MaintenanceWorker : public QObject
 {
  Q_OBJECT

 public:
  MaintenanceWorker()
  : QObject(NULL),
mTimer(NULL)
  {
  // executes in main thread
  moveToThread(mThread);
  connect(mThread, SIGNAL(started()), this,
 SLOT(onThreadStarted()));
  }
 private slots:
  void onThreadStarted()
  {
  // executes in spawned thread
  mTimer = new QTimer();
  connect(mTimer, SIGNAL(timeout()), this, SLOT(onTimerTimeout()));
  mTimer-start(6);
  }

  void onTimerTimeout()
  {
  // executes in spawned thread
  }
 private:
   QThread mThread;
   QTimer* mTimer; // to be created in thread
 };

 After porting the project from Qt 4 to Qt 5 (using Qt 5.3 now) I've
 decided to use high-level QtConcurrent facilities and namely QThreadPool
 for its ability to reuse threads, control pool size and so on. So the
 sample code above was transformed into this:

Sorry, but I'm not going to actually answer your question :)

This decision doesn't make much sense to me. The timer seems to go 
against the idea of using the threadpool in the first place. So here's 
what I would do:

1) Keep your old design. It works and unless you often delete and create 
new threads, you won't get better performance with the new code.

or

2) Move the timers to a single job creator. Possibly the same object 
that holds the thread pool. In here you create the tasks from the timers 
and give them to the pool.

A runnable object is usually a simple task that needs to be done 
sometime soon. This suggests that the tasks you have are really what 
happens when the timer fires, which is why I would expect you to go to 
number 2).

The design you implement now feels like you just want to use a different 
set of thread classes, but you don't consider what this means for your 
own code design.

So my advice is: Go all the way with the new design, or stick with what 
you have that is already working.

I hope this helps.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QtConcurrent and event-driven objects

2015-01-27 Thread Bo Thorsen
On 01/26/2015 11:56 AM, Dmitriy Purgin wrote:
 Another important thing for me is network. The docs also specify that
 the network module should also follow single thread policy. Does that
 mean that an instance of QTcpSocket can't be used in QRunnable started
 by QThreadPool?

You can only use the socket in one thread at a time. You can pass it on 
to another thread, but you will find yourself with weird bugs if you do 
this a lot.

You haven't given enough information to say if this is a problem for you 
or not. If the threads just send stuff over the socket, then implement 
this with simple message parsing to the thread that have the socket. If 
the threads handle incoming messages (which I wouldn't expect, since 
you're using timers instead of handling incoming data signals), the 
answer depends on whether your protocol allows out of sync answers or not.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Order of events on shutdown...

2015-01-23 Thread Bo Thorsen
Den 23-01-2015 kl. 17:15 skrev Igor Mironchik:
 Hi.

 Does somebody know what is the order of events on shutdown of application?

 Say, if I click close button on window - close event occurs... What next?
 What signals will be emitted from QApplication? What events?

 And the same question for mobile platforms? If I press Home button what
 will be with application?

 I need it to carefully close application, close sockets, etc...

QCoreApplication::aboutToQuit() is your friend. If you connect a slot to 
that, you can close everything there.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] WA_NoSystemBackground vs WA_OpaquePaintEvent

2015-01-21 Thread Bo Thorsen
Hi Philippe,Den 21-01-2015 kl. 15:32 skrev Philippe:
 The difference between these two modes is not obvious.
 When should we use *WA_NoSystemBackground* instead of *WE_OpaquePaintEvent*,
 and reciprocally?
 When should we use both?
 I could not get any clear hint while searching through the Qt source...

WA_NoSystemBackground tells QWidget that it should not fill the window 
with the standard widget background. If this is not set, it's possible 
that the paint of a widget is opaque. Qt tries to figure this out 
automatically.

WA_OpaquePaintEvent says to QWidget that you know for a fact that your 
painting of the window will fill up everything. The widget uses this 
knowledge to optimize out some of the things it does before calling the 
widget paintEvent (filling the background is one).

WA_NoSystemBackground doesn't say that your painting of the widget will 
cover the widget completely. This allows you to do some extra 
transparency in your widgets or windows.

If you have set WA_OpaquePaintEvent you don't really need 
WA_NoSystemBackground because the effect is covered. Or that is at least 
what it looks like when I look at the current sources. I normally set 
both anyway, as there might be some subtle difference in future versions.

WA_OpaquePaintEvent is all about optimization. For a lot of custom 
widgets it's not really necessary to worry about them. Of course, we 
don't like to waste cpu cycles, but the painting system in Qt is so fast 
that if this is a small widget you are not going to see any difference. 
But if your painting of the widget does fill the entire widget, you 
should set this.

WA_NoSystemBackground is not about optimization, it is a control you 
have to set whether Qt will paint something on the widget before your 
paintEvent is called.

I hope this helps.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt 5.3 vs Qt 5.4 (etc)

2015-01-20 Thread Bo Thorsen
Den 20-01-2015 kl. 11:47 skrev René J.V. Bertin:
 On Monday January 19 2015 19:33:21 Thiago Macieira wrote:

 By the way, I've been meaning to add a patch to Qt that would cause one
 library to use a symbol from QtCore that has the exact Qt version number in
 its ELF symbol. Would this help in the packaging and ensuring everything is
 ship-shape?

 Like the GLIBCXX_3.4.20 version that the other thread is talking about, but
 removing that symbol in a new version.
 But wouldn't that break backwards compatibility?

Actually the exact opposite. Doing this allows a library to have several 
binary incompatible versions of the same symbol in one library. glibc 
does this a lot.

The problem for Qt is that it has to be the same for all platforms, and 
I'm not sure this is something that's supported on systems that don't 
use gnu binutils.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


[Interest] Qt japanese onscreen keyboard

2015-01-16 Thread Bo Thorsen
Hi everyone,

I have a request for an onscreen japanese keyboard for a Qt application. 
Later it will also have Korean, Russian and a bunch of others.

There are several problems with this. For example, should it be a 
keyboard that shows japanese chars on the keys? If yes, I think there 
are more than one of those.

If not, then we'll show the normal ascii chars and do a conversion with 
the input. As I understand it, this is what the mobile world does? 
Setting the locale on a line edit to japanese and sending key events 
doesn't seem to give me any Japanese chars.

Did someone here already implement this? Any pointers? I have done a 
google search for this, but nothing useful came up. I hope you guys can 
help.

Thanks,

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


Re: [Interest] Qt japanese onscreen keyboard

2015-01-16 Thread Bo Thorsen
Den 16-01-2015 kl. 12:48 skrev Harri Porten:
 On Fri, 16 Jan 2015, Bo Thorsen wrote:

 If not, then we'll show the normal ascii chars and do a conversion with
 the input. As I understand it, this is what the mobile world does?
 Setting the locale on a line edit to japanese and sending key events
 doesn't seem to give me any Japanese chars.
 I am almost as clueless as you but I'll provide one hint that got me once
 going: QInputMethod :)

The implementation I'm working on has a QLineEdit that shows the current 
input text. So I simply send synthetic keyboard events to the line edit. 
This one already has QInputMethod handling, so that part is already covered.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


Re: [Interest] QTextStream doesn't write to QFile

2015-01-16 Thread Bo Thorsen
Den 16-01-2015 kl. 13:01 skrev Igor Mironchik:
 Hi.

 On Fri, 16 Jan 2015 14:44:08 +0300, Koehne Kai
 kai.koe...@theqtcompany.com wrote:


 -Original Message-
 From: interest-bounces+kai.koehne=theqtcompany@qt-project.org
 [mailto:interest-bounces+kai.koehne=theqtcompany@qt-project.org]
 On Behalf Of Igor Mironchik
 Sent: Friday, January 16, 2015 12:24 PM
 To: interest@qt-project.org
 Subject: [Interest] QTextStream doesn't write to QFile

 Hi. I'm doing a simple log class. I'm sure that Log creates after
 QCoreApplication.
 QCoreApplication is static. I create QCoreApplication as:

 static QSharedPointer QCoreApplication  application(
 int argc = 0, char ** argv = 0 )
 {
 static QSharedPointer QCoreApplication  app(
 new QCoreApplication( argc, argv ) );

 return app;
 }
 It seems you're desperately trying here to extend QCoreApplications
 lifetime as long as possible. This is just asking for trouble: just let
 QCoreApplication be destructed when your application exits, in main.cpp.
 I'm not desperately trying to extens QCoreApplication lifetime. I need it
 for that reason that Log is singleton and uses QObjects. So Log have to be
 destructed before QCoreApplication.

 It's normal practice when using singletons in Qt apps. It works well in
 other my application.

If you want to delete the singletons before the QApplication, call a 
delete on them after exec() returns. The order of static deletes is 
undefined.

It does not work well in any application other than by pure chance.

But why would you think that a QObject can't be deleted after 
QApplication? That works fine, as long as you don't do something else in 
the destructors that use any objects deleted by the QApplication.

One thing you can do to make certain objects are deleted before the qApp 
is to make qApp the parent of the singletons. This also works if 
QApplication is instantiated on the stack.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


Re: [Interest] Qt japanese onscreen keyboard

2015-01-16 Thread Bo Thorsen
I obviously already told them about this, Tuukka. But the virtual 
keyboard is not available for Windows and they have been using the LPGL 
version for 10 years and won't change this decision.

Bo.

Den 16-01-2015 kl. 14:05 skrev Turunen Tuukka:
 Hi,

 There already is an excellent virtual keyboard for Qt, please see:
 http://doc.qt.io/QtVirtualKeyboard/index.html

 This is part of the commercial offering, intended for device creation.

 As announced at the Qt Developer Days support for Japanese and Korean
 languages will be added to it. There already are many other languages
 supported, check the link for a full list.

 If you want to check it out, you can take the current version for a spin:
 http://www.qt.io/download/ (select Free 30-day Trial and then Qt for
 Device Creation from the drop down menu).

 Yours,

 Tuukka Turunen
 Director, RD

 The Qt Company
 Piippukatu 11, 40100 Jyväskylä, Finland
 Email: tuukka.turu...@theqtcompany.com | Mobile: + 358 40 7655 800
 www.qt.io |Qt Blog: http://blog.qt.digia.com/ | Twitter: @QtbyDigia,
 @Qtproject | Facebook: www.facebook.com/qt





 On 16/01/15 14:53, Alejandro Exojo s...@badopi.org wrote:

 El Friday 16 January 2015, Bo Thorsen escribió:
 If not, then we'll show the normal ascii chars and do a conversion with
 the input. As I understand it, this is what the mobile world does?
 Setting the locale on a line edit to japanese and sending key events
 doesn't seem to give me any Japanese chars.
 It's a bit complex. The Japanese language, as far as I know, seems to
 always
 require an input system. Either they type romaji (characters in the
 roman
 alphabet), and a certain UI allows you to choose between different
 possibilites, or they type kana (the sillabary).

 For example, I typed Japanese in Japanese, nihongo, and I was offered 日
 本語
 which is kanji or にほんご which is the same in kana. There are thousands
 or
 kanji, but only about 50 kana (actually, in two versions, but that's
 another
 story). That means that natives might prefer to type kana, which is what
 they
 learn as children, but foreigners might want the romanized version of the
 word.

 Did someone here already implement this? Any pointers? I have done a
 google search for this, but nothing useful came up. I hope you guys can
 help.
 What constraints there are? For Linux the tipical solution is Maliit, but
 how
 well the japanese plugin works is an unkown. The website seems a bit
 broken. I
 think it heavily used D-Bus, but I saw some post about Windows support.

 http://web.archive.org/web/20131218195654/https://wiki.maliit.org/Main_Pag
 e
 https://web.archive.org/web/20130606035734/https://wiki.maliit.org/Documen
 tation/Installing#From_source_code_.28Windows.29
 https://code.google.com/p/maliit-plugin-jp/
 https://gitorious.org/maliit-plugin-jp

 Good luck!

 -- 
 Alex (a.k.a. suy) | GPG ID 0x0B8B0BC2
 http://barnacity.net/ | http://disperso.net
 ___
 Interest mailing list
 Interest@qt-project.org
 http://lists.qt-project.org/mailman/listinfo/interest
 ___
 Interest mailing list
 Interest@qt-project.org
 http://lists.qt-project.org/mailman/listinfo/interest


-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


Re: [Interest] How can I use QPointer as an argument?

2015-01-13 Thread Bo Thorsen
Den 13-01-2015 kl. 04:13 skrev Guenther Boelter:
 I have a 'small' problem and my timeline is running so fast ...

 How can I use QPointer as an argument? A simple

 void myFunction( QPointer *myPointer )
 {
  // do something
 }

 myFunction( myPointer );


 returns 'error: ‘QPointer’ is not a type'.

You don't need to copy the QPointer. A QPointer is a weak pointer class. 
It is told by the object it holds, if it's deleted, and then switch to a 
null pointer.

So in your case, you simply give the object it holds to your function 
instead.

If you want to, you can create a QPointer in your function.

void myFunction(QObject* o) {
   QPointer p(o);
   // do something
}

QPointer p(theRealObject);
myFunction(p.data());

I hope this helps.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


Re: [Interest] Advice on random program finish crash

2015-01-07 Thread Bo Thorsen
Den 07-01-2015 kl. 11:30 skrev Nuno Santos:
 Hi Igor,

 Ops… You are right, it is not static.

 I have tried your suggestion but now it crashes everytime I close the
 app and I can’t even get a stack trace like before. If I run it on
 debug, it points me to assembler code. Not anything I can really point to.

 Regards,

 Nuno


 On 07 Jan 2015, at 10:19, Igor Mironchik igor.mironc...@gmail.com
 mailto:igor.mironc...@gmail.com wrote:

 On Wed, 07 Jan 2015 13:01:32 +0300, Nuno Santos
 nunosan...@imaginando.pt mailto:nunosan...@imaginando.pt wrote:

 Yes,

 int main(int argc, char **argv)
 {
QGuiApplication app(argc, argv);

...

return app.exec();
 }

 No. Here QGuiApplication is not static. Then in your app the situation
 is the next: QGuiApplication destroyes before your Manager. But any
 QObject-derived class must be created after QApplication and destroyed
 before QApplication. May be this is the reason of your crash.

 Make QGuiApplication static. For example:

 static QSharedPointer QApplication  application( int argc = 0, char
 ** argv = 0 )
 {
 static QSharedPointer QApplication  app(
 new QApplication( argc, argv ) );

 return app;
 }

 and in main()

 QSharedPointer QApplication  app = application( argc, argv );

 before any QObject...



 On 07 Jan 2015, at 09:54, Igor Mironchik igor.mironc...@gmail.com
 mailto:igor.mironc...@gmail.com wrote:

 Hi, I have one question: is QApplication static too?

This probably doesn't make any difference. What this does is to defer 
the destruction of the QApplication object until the main() method is 
done, which effectively makes sure you delete QApplication last.

EXCEPT that it doesn't work :) Because you can't guarantee that there 
are no QObject derived static objects from other methods that are 
deleted after.

Forget this and stay with a normal heap allocated QApplication object. 
If this causes any trouble, you need to find the reason for it instead 
of trying a workaround that at best makes the problem a bit less likely 
to surface.

There are (at least) three things I do for random crashes:

1) Build on Linux and run it in valgrind if you can.
2) Run it in a debugger where you have the Qt sources registered so you 
get backtraces that have meaning.
3) Comment out creating as many objects as you can so the problem 
becomes visible with as few as possible. This minimizes your object 
interactions so the problem is easier to track.

And if you're using threads: 4) Replace all start() with run() and pray 
your problem still exist.

I hope this helps.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] How to do it better?

2014-12-30 Thread Bo Thorsen
Den 30-12-2014 kl. 11:26 skrev Igor Mironchik:
 Hi,

 On Tue, 30 Dec 2014 11:41:05 +0300, Till Oliver Knoll
 till.oliver.kn...@gmail.com wrote:


 Am 30.12.2014 um 05:24 schrieb Igor Mironchik
 igor.mironc...@gmail.com:

 Hi,

 cool, after a whole day of work

 My whiskey tasted great yesterday evening (also after a day of work, and
 after a great self-made dinner with friends).


 Fresh sight can be much more better than hours of work. :)



 ;)

 my brain is clouded.

 Ah, I wasn't aware that you were looking for a Cloud(tm)-based solution!

 ;)

 Ok, whiskey and jokes aside: your base class could also simply emit a Qt
 signal (to relate this thread a little bit with Qt) whenever that
 property changed (again, setter/getter accesss, make sure the property
 actually /did/ change before emitting the signal, ... you know the game).

 Your derived class could then simply connect to itself (to that
 signal) and react accordingly in its own slot.


 But I have to ask: for me it sounds like your base class is some kind of
 data (Model) class, and your derived class a QWidget-based class, aka
 the View (you've mentioned QResizeEvent). Or in other words: does your
 derived class inherit from two base classes: your Model and some
 QWidget class (multiple inheritance)?

 If yes: why not a has-a relationship between your Model (currently
 your base class) and your View (currently your derived class),
 instead of your current is-a situation?

 If no, then why does your base class (which must then be a QWidget based
 one in this case) not handle the resize event itself; derived classes
 could still overwrite the resize method and add custom code, e.g. after
 (or before) calling the base class' resize method?



 The situation is the next. My base class is QWidget-based implented
 signals, slots and properties. And my derived class is template class that
 doing actual work. And in setter of one property I had to
 recalculateSize() in template class, and template method pattern is very
 good in this situation...

In proper Qt based architectures, template method patterns are not as 
common as in other places. At least not if you code Qt like I do. Using 
a template method means the base class decides when the sub classes do 
something. That's a very tight coupling between the base class and 
subclasses. Tight coupling means you're one step closer to the dreaded 
spaghetti code.

I (almost) always preach using signals to avoid tight coupling. By 
emitting a signal in the base class when the property changes, you stop 
this class from knowing what subclasses do. Or any other use that you 
might think of in the future. This means your class becomes a black box 
that needs no info about the other classes.

In case you're not convinced yet, try this thought experiment: If you 
already had a working system where classes are working well. Now your 
subclass changes an implementation detail, so you need the geometry 
recalculation on this property change. So to do that you have to 
implement the logic for this in the base class? That just smells bad. 
With just one subclass this isn't so bad, but how do you know that you 
won't have more in the future?

I don't like the template method pattern in cases like this because it 
moves responsibility from the class where it belongs. Template method 
should be used when the base class orders *all* subclasses to handle 
something. Not in particular cases like this one where it's the subclass 
that needs something done.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Testing with Windows Phone, first impressions

2014-12-30 Thread Bo Thorsen
Den 30-12-2014 kl. 11:48 skrev Harri Pasanen:
 Note that I cannot
 run the emulator, VirtualBox does not expose the hardware virtualisation
 support to guests and the emulator requires it.

If you use qemu/kvm you can do nested virtualization.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Strange behaviour of QByteArray reserve/reallocation mechansim

2014-11-10 Thread Bo Thorsen
Hi Bernhard,

Den 09-11-2014 kl. 10:34 skrev Bernhard:
 I just experienced a strange behavior of QByteArray regarding its internal
 reallocation behavior. Actually that behavior stops me from using
 capacity()/reserve() to optimize the allocation behavior and its seem to me
 that under current conditions reserve() is more or less useless. Using the
 current implementation there is no way of avoiding continuous reallocations
 while using QByteArray with data of different lengths.

 Please see the following SO post (please tell me if it is not allowed to
 post such links in this ML):

 http://stackoverflow.com/questions/26821207/internal-reallocation-behaviour-
 of-qbytearray-vs-reserve

 Is this actually desired behavior? Is it a bug?

Desired? No. Bug? Maybe.

It depends entirely on your definition on what reserve() should support. 
For example, if you do this:

QByteArray a, b;
a.reserve(1000);
a = b;

There's no way you will ever preserve the reserve(), because that would 
conflict with the implicit sharing.

So in your case you use another operator=. Should that work? Well, if it 
does I'm sure no one would object. But since another operator= can never 
hold the reserve() promise, I don't really see the point.

reserve() means you can write directly in the byte array data, and then 
it works. I'd suggest that you follow this rule. You can do this by 
working directly on the data() pointer.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Sorting numbers in QSortFilterProxyModel with QSqlTableModel source

2014-11-03 Thread Bo Thorsen
Den 01-11-2014 08:26, resurrect...@centrum.cz skrev:

 By default QSortFilterProxyModel can sort few different types using 
 QVariant::type to see what is in it to do the correct sort. However 
 when the QSqlTableModel is used then this always evaluates to QString 
 (the default) and thus sorts numbers as strings. I wrote my own 
 subclass of the filter model to force sorting by number but I wonder 
 if there is a way to tell the QSortFilterProxyModel by what type it 
 should sort? I know that the problem is obviously with QSqlTableModel 
 disregarding the types of fields in the database but that is hardly 
 something that could be influenced that easily.


I always find myself writing the full sorting myself. The default 
implementation is fine to get something up and running quickly, but at 
some point I implement my own.

Looks like you're on the same path.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


Re: [Interest] How can I block the WindowActivate and FocusIn events when showing window programmatically

2014-10-31 Thread Bo Thorsen
Den 30-10-2014 20:30, Yili Pan skrev:
 Hi:

 We want to block the widget's WindowActivate and FocusIn event 
 triggered by calling its show() function, with Qt4,  we used to do 
 that by setting flag before and after show() and filter out the event 
 in eventfilter based on the flag.  But with Qt5, the events are 
 processed asynchronously, we cannot block the event in the same way 
 anymore.

 Any ideas how I can identify those events that are caused by calling 
 QWdiget::show() and filter them out?

You can use an event filter for this. Take a look at the documentation 
for QObject::installEventFilter, it should be simple to follow.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


Re: [Interest] Loading QML plugins without registered types

2014-10-20 Thread Bo Thorsen
Den 19-10-2014 kl. 21:15 skrev Oleg Shparber:
 I have a plugin which does not provide any QML types and needs only
 initializeEngine() method to be executed. The problem is that the plugin
 is not registered with QML Engine when it doesn't have any types. That
 leads to an error with import statement:

 qrc:/main.qml:4 module com.wisetroll.nodeqml is not installed

 Right now I worked the problem around by registering a fake object:

 qmlRegisterTypeQObject(uri, 1, 0, __nodeQmlUselessObject);

 I couldn't find any other way to make my plugin work. Am I missing a
 proper way of loading plugins with no types?

 If there's no other way, my suggestion would be to add a new directive
 to qmldir, that would tell QML engine to keep register plugin regardless
 if it provides types or not.

I guess people would have thought that any QML plugin would register 
types. If it doesn't do this, then it's not a QML plugin.

I suspect that what you are doing here is to use the QML plugin system 
to load what is really a normal plugin for your C++ layer. In that case, 
you should use the standard Qt plugin system.

If this isn't the case, please describe what you are doing and why you 
think it's the right idea to break the fundamental assumption of the plugin.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] How to set QtQuickControls Slider to an initial value without modifying the current saved?

2014-10-17 Thread Bo Thorsen
Den 16-10-2014 17:39, Nuno Santos skrev:
 Hi,

 I’m using Slider from QtQuickControls and i’m facing a problem. I initialise 
 the value with a value saved on settings. However, when the slider is 
 instantiated, it is triggering onValueChanged with the default min value. The 
 setting is being correctly saved because I don’t show the slider right away. 
 Only when the slider is show, this is happening and I see the result of the 
 change in settings.

 Slider {
  width: parent.width
  height: 10
  minimumValue: 60
  maximumValue: 180
  stepSize: 1
  updateValueWhileDragging: true
  value: settings.trackWidth
  onValueChanged: {
  console.log(track width value changed:  + value)
  settings.trackWidth = value
  }
  Component.onCompleted: {
  console.log(track width on completed:  + settings.trackWidth)
  value = settings.trackWidth
  }
 }

 Console:

 qml: track width value changed: 60
 qml: track width on completed: 60

It's possible there is an elegant solution to this, but I haven't found 
it so far. What I do in cases like this is to set a boolean property 
initialised to false and set this to true in onCompleted after you set 
the value. In onValueChanged, you check if the bool is true before doing 
anything on the value.

Bo.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu

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


  1   2   3   >