Results 1 to 4 of 4

Thread: cant open file newby problem

  1. #1
    Join Date
    Jan 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default cant open file newby problem

    Hi, I have some old program in C implementing in Qt4, an I`m trying to open file with fopen, and it give me errors when i compile it:

    Qt Code:
    1. QString path, path2;
    2. FILE *vstup;
    3.  
    4. path2 = lineEdit->text();
    5. path = path2.section('/', -1); //it cuts from path to file the name of file name
    6.  
    7. vstup=fopen(path,"r");
    To copy to clipboard, switch view to plain text mode 
    The problem is in variable path, i don`t now how to convert it into right type for fopen. Thank`s you for any advice.
    Last edited by jpn; 27th January 2009 at 13:53. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: cant open file newby problem

    See QFile. Notice the example usage in detailed description part of the docs.
    J-P Nurmi

  3. #3
    Join Date
    Jan 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cant open file newby problem

    Thank`s, I know about Qfile, but when I open text file with qfile, i don`t now equivalent to this C funktions:

    Qt Code:
    1. c=fgetc(vstup);
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. fputc(c,vystup);
    To copy to clipboard, switch view to plain text mode 

    I was trying, it was something like this in Qfile:
    Qt Code:
    1. c=getChar(vstup);
    To copy to clipboard, switch view to plain text mode 
    but its fo course not good

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: cant open file newby problem

    QFile inherits QIODevice. Most of the reading and writing functionality is available in QIODevice API. See QIODevice docs for more details.

    PS. You're now dealing with C++. Refer to your favorite C++ book on how to call member functions...
    J-P Nurmi

Similar Threads

  1. QDesktopServices open url & local file & pdf or doc
    By patrik08 in forum Qt Programming
    Replies: 9
    Last Post: 14th April 2012, 04:42
  2. Exclusive file creation (Samba shares)
    By marcel in forum General Programming
    Replies: 1
    Last Post: 13th April 2007, 12:26
  3. How to open a Pdf file from Qt
    By vishal.chauhan in forum Newbie
    Replies: 2
    Last Post: 28th March 2007, 08:24
  4. Qt 4.1.4 on VS2005 error- cannot open input file 'qtmain.lib'
    By Ashish in forum Installation and Deployment
    Replies: 10
    Last Post: 11th October 2006, 16:05
  5. QProcess open all file -> url.dll,FileProtocolHandler
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 26th June 2006, 17:07

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.