October 6, 2010

s.frings s.frings
Lab Rat
40 posts

Why does QT use so few exceptions?

Page  
1

Hi,
I am developing Java programs since 3 years, so I very often work with exceptions. I wonder why QT does not use them as oftens. It seems that they are used as less as possible. Can somebody explain, why?

16 replies

October 6, 2010

Tobias Hunger Tobias Hunger
Robot Herder
3386 posts

When Qt was started exceptions were not available for all the compilers that needed to be supported by Qt. Today we are trying to keep the APIs consistent, so modules that have a history of not using exceptions will generally not get new code using exceptions added.

You will notice exceptions are used in some of the new modules of Qt.

October 6, 2010

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

Tobias, does it mean that some day (version of Qt like 6.10) we will have exception-style error handling in Qt, not error()-methods?

October 6, 2010

Tobias Hunger Tobias Hunger
Robot Herder
3386 posts

Denis: For consistency we should not mix error handling styles in modules, so I can not see this happen without causing a mayor version number change (since the non-exception style would need to get removed which will break source compatibility).

But this is just my opinion: I am not aware of any plans for Qt 5 or later.

October 6, 2010

danilocesar danilocesar
Lab Rat
161 posts
Tobias Hunger wrote:
But this is just my opinion: I am not aware of any plans for Qt 5 or later.

NOOOOOOO!!! =P

 Signature 

Danilo Cesar Lemes de Paula
Software Engineer

October 6, 2010

Tobias Hunger Tobias Hunger
Robot Herder
3386 posts

danilocesar: What was that NOOOOO about?

October 6, 2010

danilocesar danilocesar
Lab Rat
161 posts

It’s a good place to change major architecture decisions without harm current devs.
From a simplistic point of view (without thinking about continuous improvement of current apps, kde, nokia, market, etc), who doesn’t want Qt 5? :)

 Signature 

Danilo Cesar Lemes de Paula
Software Engineer

October 6, 2010

MTK358 MTK358
Lab Rat
27 posts
Tobias Hunger wrote:
danilocesar: What was that NOOOOO about?

Just read this sentence and forget about the context of this thread:

“I am not aware of any plans for Qt 5 or later.”

October 6, 2010

Tobias Hunger Tobias Hunger
Robot Herder
3386 posts

MTK358: I do not know of any plans, that does not mean that nobody else is doing planning;-)

October 7, 2010

s.frings s.frings
Lab Rat
40 posts

To come back to the original question: Is there a technical reason, not to use exception to handle errors? I understood, that the reason was historically, so it’s basically a good idea to use exceptions in my own programs.

October 7, 2010

Franzk Franzk
Lab Rat
830 posts

I don’t think there would be a lot of places where Qt would really benefit from exceptions, but hey, I might be missing something :).

 Signature 

“Horse sense is the thing a horse has which keeps it from betting on people.”—W.C. Fields

http://www.catb.org/~esr/faqs/smart-questions.html

October 17, 2010

Tobias Hunger Tobias Hunger
Robot Herder
3386 posts

s.frings: Yes, there is no reason not to use exceptions in your own programs. I do not know whether it is a good idea for consistency reasons: I prefer not having to switch between exception/non-exception code, but that is just a matter of taste.

October 22, 2010

ivan.todorovich ivan.todorov..
Lab Rat
96 posts

What about QSqlError ?
I find it annoying calling lastError() every time I execute a SQL query. I can’t think of a better place to use exceptions instead of error codes. Not to mention that exceptions are thread-safe.

 Signature 

o_o Sorry for my rusted english.

October 22, 2010

szh1 szh1
Lab Rat
126 posts

What are the advantages of Exceptions?

October 22, 2010

Volker Volker
Ant Farmer
5428 posts

Some of them are explained here [parashift.com]

And keep in mind:
there is NO one size fits all! Exceptions might work wel for one case, but not for the other.

October 22, 2010

szh1 szh1
Lab Rat
126 posts

I hope Qt starts to use exceptions soon!

Page  
1

  ‹‹ Working with QTable Cellwidgets from keyboard      Managing memory in a QPlainTextEdit widget ››

You must log in to post a reply. Not a member yet? Register here!