i have displayed a message by using QMessageBox and i have done all the translation related to my message but the Yes / No option cannot be translated. So how can it be done.
i have displayed a message by using QMessageBox and i have done all the translation related to my message but the Yes / No option cannot be translated. So how can it be done.
you can get access to dialog buttons using this method
http://doc.trolltech.com/4.4/qmessagebox.html#button
so, in you case you need to do
Qt Code:
... ...To copy to clipboard, switch view to plain text mode
i have added a message in message box box , but how the Ok can be changed
this code didn't help?
Qt Code:
... ...To copy to clipboard, switch view to plain text mode
yeah it wont work.
this code works fine
Qt Code:
msg.exec();To copy to clipboard, switch view to plain text mode
i did it but it said tr identifier not found.
use QObject::tr(...)
how i can use it with set text.
and also it shows "use of undefined type Qabstract button" with button means msgBox.button
see http://doc.trolltech.com/4.4/qobject.html#tr
include
Qt Code:
#include <QAbstractButton>To copy to clipboard, switch view to plain text mode
msg.button(QMessageBox::Ok)->setText(tr("My Ok label"));
here it shows tr identifier not found.
so here how can i use QObject.
Qt Code:
... ...To copy to clipboard, switch view to plain text mode
I m doing like this:
Qt Code:
void MyMessageBox: QMessageBox(QWidget* parent, const QString& title, const QString& text, const QMessageBox&) { QMessageBox box; box.removeButton("OK"); box.addButton("OK"); box.exec(); return;To copy to clipboard, switch view to plain text mode
it is not working.
please help me out.
Last edited by jpn; 8th September 2008 at 16:31. Reason: missing [code] tags
MyMessageBox: QMessageBox
I guess u are inheriting from QMessageBox,,,
then why are u making another instance of QMessageBox inside the ctor ??
my mentor said u have to create ur own class and derive it from QMessageBox. After dat then u have to remove the already added button and add ur own buttons.
What do you want to do anyway...
in the first post ur prob was regaarding translation. Now its something else.
If you can tell what u want to achieve, may be we can tell a way..
I asked about your code. nevermind.
example
I don't see any trouble. is it hard to you?Qt Code:
----h---- #ifndef TEST_H #define TEST_H #include <QMessageBox> { Q_OBJECT public: Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); ~Test(); }; #endif ---cpp--- #include "test.h" { removeButton(ok); addButton(tr("MyButton"), AcceptRole); } Test::~Test() { } ---another_cpp_code--- .... test.exec(); ....To copy to clipboard, switch view to plain text mode
an error is coming:
'void QMessageBox::addButton(QAbstractButton *,QMessageBox::ButtonRole)' : cannot convert parameter 1 from 'QString' to 'QAbstractButton *'
Bookmarks