June 11, 2011

Danielc Danielc
Lab Rat
36 posts

Question about QMessageBox obsolete members

 

Hi!

This is my first post in this comunity. I am beginning with Qt (porting my .Net Framework application) and I have a question. The official documentation marks some QMessageBox functions/methods as obsolete and I would like to know why. I am particulary talking about critical(), information(), question() and warning(). Do they use the obsolete function setButtonText()? I am interested in changing the texts of the buttons too, but I realized that I can do that using the setText() method of the QAbstractButton pointer that I get with messageBox.button().

Greetings and thanks!

7 replies

June 11, 2011

loladiro loladiro
Lab Rat
596 posts

Where did you see that those functions are obsolete? Also, if you want to use custom message boxes you should just use the QMessageBox class and not its static member functions. Have a look into the documentation here [doc.qt.nokia.com] to see how that is done.

June 11, 2011

Danielc Danielc
Lab Rat
36 posts

I saw it here [doc.qt.nokia.com] .
I know that I should use the class in order to customize it at maximum, but I would like to know why those functions are obsolete so I can write my own function without the same errors.

Greetings and thanks!

June 12, 2011

Volker Volker
Robot Herder
5428 posts

These methods are old because they work on int values instead of StandardButton values for the various buttions. For all of them there are replacement methods that use StandardButton. The old ones are only kept to keep old code working.

June 12, 2011

Danielc Danielc
Lab Rat
36 posts

I just saw they are not the same methods. Sorry.. I thought I checked this before.

This is solved now. Please excuse me for that stupid question.

Greetings!

June 12, 2011

Volker Volker
Robot Herder
5428 posts

No problem, you’re welcome. Sometimes you can’t see the wood for the trees – you’re in good company :-)

June 12, 2011

Danielc Danielc
Lab Rat
36 posts

Just another question (should I open another topic?).

How can I translate the “Show Details” and “Hide Details” button of a QMessageBox? Yesterday I found a post (in another forum I think) that modified the text when the button was clicked, but I don’t think this is very good. How can I localizate Qt’s texts?

Greetings and thanks again!

EDIT:

I just realized that I can install a qt translator with this: qtTranslator.load(“qt_” + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
And Spanish is included in the official package, so I don’t think I have to translate it manually.

Thanks!

April 18, 2013

ulesQt ulesQt
Lab Rat
13 posts

I also used this solution… tnxs to everyone! The translations are great!!!

Danielc wrote:
Just another question (should I open another topic?).

How can I translate the “Show Details” and “Hide Details” button of a QMessageBox? Yesterday I found a post (in another forum I think) that modified the text when the button was clicked, but I don’t think this is very good. How can I localizate Qt’s texts?

Greetings and thanks again!

EDIT:

I just realized that I can install a qt translator with this: qtTranslator.load(“qt_” + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
And Spanish is included in the official package, so I don’t think I have to translate it manually.

Thanks!

 
  ‹‹ [Solved] -std=c++0x causes compilation error      [Solved] QVariant and enums ››

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