Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 41

Thread: How QMessageBox can be inherited.

  1. #21
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How QMessageBox can be inherited.

    but that was used with QPushButton, but in ur code u are using QAbstractButton. So the problem is coming when we use tr.
    that is:

    addButton(tr("OK"), QMessageBox::Ok);

    error is:

    'void QMessageBox::addButton(QAbstractButton *,QMessageBox::ButtonRole)' : cannot convert parameter 1 from 'QString' to 'QAbstractButton *'

  2. #22
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How QMessageBox can be inherited.

    I built this code before post it.

  3. #23
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How QMessageBox can be inherited.

    so now what should i do. pls help me.

  4. #24
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How QMessageBox can be inherited.

    try this project
    Attached Files Attached Files

  5. #25
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How QMessageBox can be inherited.

    hello sir, i m doing just like this, but still it is giving the same error.

  6. #26
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How QMessageBox can be inherited.

    ok, I don't understand why this happens. anyway, try this insted
    Qt Code:
    1. ...
    2. QPushButton *myOk = new QPushButton(tr("Ok"));
    3. addButton(myOk, AcceptRole);
    4. ...
    To copy to clipboard, switch view to plain text mode 

  7. #27
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How QMessageBox can be inherited.

    now two errors r cuming.

    1) 'QPushButton' : class has no constructors
    2)'void QMessageBox::addButton(QAbstractButton *,QMessageBox::ButtonRole)' : cannot convert parameter 1 from 'QPushButton *' to 'QAbstractButton *'

  8. #28
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How QMessageBox can be inherited.

    include QPushButton or just QtGui.

  9. #29
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How QMessageBox can be inherited.

    What Qt version are u using ? Are ur paths properly included ?

    I tried the test.zip, and it works fine without any error. I have Qt 4.3.4.

  10. #30
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How QMessageBox can be inherited.

    what abt this error:

    'void QMessageBox::addButton(QAbstractButton *,QMessageBox::ButtonRole)' : cannot convert parameter 2 from 'QMessageBox::StandardButton' to 'QMessageBox::ButtonRole'

  11. #31
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How QMessageBox can be inherited.

    i have used 4.3.2

  12. #32
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How QMessageBox can be inherited.

    Where are u getting that error ?
    What i did was extracted the test.zip, ran qmake -tp vc , and built the project from visual studio. No errors.

    I dont know what u are doing... u must be missing something

  13. #33
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How QMessageBox can be inherited.

    i m just doing the same , but it is giving an error which i have already told.

  14. #34
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How QMessageBox can be inherited.

    Quote Originally Posted by rajveer View Post
    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.
    It's enough to provide translations for the proper context and message. Look into the source code of QMessageBox to see what it expects. There is really no need to making things more complex than they really are.

  15. #35
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How QMessageBox can be inherited.

    Its not working , how the QMessageBOx button can be translated.

  16. #36
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How QMessageBox can be inherited.

    What is not working? What exactly did you do?

  17. #37
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How QMessageBox can be inherited.

    use QObejct::tr and Qt Linguist for translation.

  18. #38
    Join Date
    Jul 2008
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How QMessageBox can be inherited.

    i have to change all the buttons which are coming when we are using QMessageBox in the application . the text message is changed by using tr but the OK , yes, No buttons can not be changed. so how can i do this?

    my mentor said u hav to create a class and derive it from QMessageBox and then remove that buttons and add ur own buttons. but how can i do that. means i have using it in one way which the other sir told me in the forum.

  19. #39
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How QMessageBox can be inherited.

    You don't have to do anything like that. Read my post again, it says exactly what you need to do and believe me it will work as Qt does it exactly the same when it translates the message box with a proper translator installed.

  20. #40
    Join Date
    Sep 2008
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How QMessageBox can be inherited.

    My distribution of Qt has translation files for a bunch of languages, which translates the texts and labels of the standard Qt buttons (and possibly other standard stuff as well).
    If you install a translator loaded with the correct file your standard buttons will have their text translated for you.
    Would that answer your needs?
    in my PC the translations are located in C:\Qt\4.4.0\translations\*
    Pick the one that suits you and then install it using this code:
    Qt Code:
    1. QString trans_file("<translation_file_path>");
    2. trans_file = trans_file.toLower();
    3. QTranslator qtTranslator;
    4. qtTranslator.load(trans_file);
    5. qApp.installTranslator(&qtTranslator);
    To copy to clipboard, switch view to plain text mode 
    cheers,
    --to

Similar Threads

  1. QMessageBox buttons appearance
    By yartov in forum Qt Programming
    Replies: 6
    Last Post: 26th June 2008, 01:36
  2. Display row Number in QMessageBox
    By arunvv in forum Newbie
    Replies: 6
    Last Post: 1st May 2008, 23:24
  3. Re: Help on QMessageBox
    By arunvv in forum Newbie
    Replies: 2
    Last Post: 25th March 2008, 23:45
  4. Qt4: Sorting QAbstractItemVew inherited view
    By nando in forum Qt Programming
    Replies: 3
    Last Post: 12th February 2008, 18:30
  5. QMessageBox problem in Qtopia
    By jogeshwarakundi in forum Qt for Embedded and Mobile
    Replies: 5
    Last Post: 8th February 2008, 09:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.