Results 1 to 9 of 9

Thread: fgets in Qt(Gui mode)

  1. #1
    Join Date
    May 2009
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default fgets in Qt(Gui mode)

    Hi All,

    I am facing one problem.I have one existing code written in C ,I want to use Qt functionality(GUI) to make it more user friendly .
    Problem:-
    One part of the code contains fgets() operation ,which is called when certain file is missing and user has to specify file path in command window("cmd" in windows).
    I have compiled the code using qt application(GUI) mode,but it is not calling the command window which is leading my program to crash.

    PS:- It is working absolutely fine in CONSOLE Mode.

    Can anyone help me with this?

    Thanks in advance.

  2. #2
    Join Date
    Jun 2008
    Location
    Germany/Belarus/Sweden
    Posts
    53
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: fgets in Qt(Gui mode)

    why don't you let user specify file path in GUI? look at QFileDialog...

  3. #3
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: fgets in Qt(Gui mode)

    replace fgets with QInputDialog

  4. #4
    Join Date
    May 2009
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: fgets in Qt(Gui mode)

    Thanks for your quick reply.
    I can use QFileDialog,QInputDialog but I don't want to change the existing code. Is there some way to call cmd window automatically as soon as program encouters fgets() ?
    How it works absolutely fine in "Qt Console" mode?

    Even Qt GUI mode contains QtCore libraries , there must be some some way out of this mess.I think I am missing some thing.

  5. #5
    Join Date
    May 2009
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: fgets in Qt(Gui mode)

    I think GUI thread is blocking console application. I know it can be invoked using QProcess::startDetached("cmd.exe") ,or I can use QInputDialog/QFileDialog.

    Limitation :- I can't do changes inside C code since they are using fgets() throughout the application to prompt user for input.

    Problem:- I want to handle fgets using GUI thread,to get the same feel as if I have compiled the code for Qt cosole application.

    Thanks.

  6. #6
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: fgets in Qt(Gui mode)

    why cant u change the code??

  7. #7
    Join Date
    May 2009
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: fgets in Qt(Gui mode)

    It's a 18 years old legacy code written in "C" contains 2,86063 lines with fgets in more than 100 places.
    I have already created GUI for that with all interface,if no other option I will have to go for this bull work.Before this I want to be 100% sure that there is no other way than to change the whole code and replace it with "QInputDialog/QFileDialog" etc...

  8. #8
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: fgets in Qt(Gui mode)

    i dont have exp in console apps... and your situation is unique...

    if i were u then i would just search and replace the fgets as

    Qt Code:
    1. search
    2. fgets(char*,xx,xx,xx);
    3. replace with
    4. myFgets(char*,xx,xx,xx);
    5.  
    6. its a very easy thing and u dont have to do anything if u use any text editor..
    7.  
    8. then make your function
    9. myFgets(char* str,xx,xx,xx)
    10. {
    11. str=(convert string char by char);
    12. }
    To copy to clipboard, switch view to plain text mode 

  9. #9
    Join Date
    May 2009
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: fgets in Qt(Gui mode)

    Sorry I didn't explain the whole scenerio. My application has two modes "GUI" and "Console" ,user can opt for any using Config file(which I have yet to create). Application has to read that file and load the application accordingly(console/gui mode).

    Now my problem is how can I do this? I don't want two different exe for console and GUI
    That's why I am searching for some solution to control console using GUI so that only one exe is enough.

Similar Threads

  1. Solutions for invoking QWhatsThis Mode
    By ike in forum Qt Programming
    Replies: 9
    Last Post: 28th May 2009, 19:18
  2. Replies: 9
    Last Post: 15th April 2009, 06:23
  3. Not able to execute in Release Mode
    By sudheer168 in forum Qt Programming
    Replies: 4
    Last Post: 18th March 2009, 11:58
  4. Replies: 2
    Last Post: 22nd July 2007, 19:21
  5. qodbc driver not loaded error in release mode
    By mandal in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2006, 09:42

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.