Results 1 to 2 of 2

Thread: How to set text to messageBox from a function outside of mainWindow

  1. #1
    Join Date
    Jan 2016
    Posts
    22
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to set text to messageBox from a function outside of mainWindow

    Hello Everyone,

    I am working with Qt in order to display the text obtained from the return statement of a function.

    So I have a function of type Stat init(), where Status is a typedef struct which contains code and error messages of type char *.
    My function looks like this

    Stat init()
    {
    stat msg;
    msg.code = ERROR; //ERROR is a enum
    if(.......)
    {
    msg.errorcode = "some message";
    }

    return msg;
    }

    This function is inside a .cpp file.

    Now I have an another file named MainWindow.cpp.

    In this file I include the header file of the above file, so that I can use stat init() function. Now I should display the msg in a messagebox like a warning or an information. Can someone give me an idea how I can set text such that it gets the information from Stat init().

    Thank you.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to set text to messageBox from a function outside of mainWindow

    QMessageBox has some convenience static functions for that, where you basically just have to pass the text.

    Cheers,
    _

Similar Threads

  1. Replies: 11
    Last Post: 5th September 2012, 20:47
  2. MessageBox comes before MainWindow
    By fakandere in forum Qt Programming
    Replies: 3
    Last Post: 3rd July 2012, 02:22
  3. Replies: 1
    Last Post: 8th January 2012, 11:33
  4. Replies: 2
    Last Post: 30th July 2010, 15:59
  5. set Bold to MessageBox particular Text
    By BalaQT in forum Qt Programming
    Replies: 2
    Last Post: 5th November 2009, 11:53

Tags for this Thread

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.