Results 1 to 1 of 1

Thread: 'Open with' & compiler problems

  1. #1
    Join Date
    Mar 2016
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: 'Open with' & compiler problems

    Hello, i'm trying to make a text edit but i've problems with "open with".
    I would like that when i'm on my desktop and right click on a file (.txt for instance) -> open with -> MyApp, the text shows in a QTextEdit

    For now, i've that :
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6. QString file = QFileDialog::getOpenFileName(this, "Open a file", "", tr("Text files (*.txt) ;; All files (*.*)") );
    7.  
    8. if ( !file.isEmpty() )
    9. {
    10. QFile sFile ( file );
    11. if ( sFile.open(QFile::ReadOnly | QFile::Text) )
    12. {
    13. QTextStream in(&sFile);
    14. QString text = in.readAll();
    15. sFile.close();
    16.  
    17. ui->textEdit->setPlainText(text);
    18. }
    19. }
    20. }
    To copy to clipboard, switch view to plain text mode 
    But it doesn't do what I would like. :'(

    ---------------------------------------------

    My second problem is when I call :

    Qt Code:
    1. QFileDialog::getOpenFileName
    2. or
    3. QFileDialog::getSaveFileName
    To copy to clipboard, switch view to plain text mode 

    there is a little message in debug :

    shell\comdlg32\fileopensave.cpp(9456)\COMDLG32.DLL !764F0750: (caller: 764E3458) ReturnHr[PreRelease](1) tid(630) 80070490 Element not found.
    CallContext:[\PickerModalLoop\InitDialog\FileDialogInitEnterpri seData]
    despite this, it works anyway. How can i solve this "false" error ?


    Added after 1 3 minutes:


    i solved my first problem, I used

    Qt Code:
    1. if (QApplication::arguments().size() > 1) {
    2. const QString FILENAME = QApplication::arguments().at(1));
    3. }
    To copy to clipboard, switch view to plain text mode 

    so it returns me the path and the name of the file i wanna open.
    source : http://stackoverflow.com/questions/3...qt-application

    -----------------

    My second problem is still unsolved.
    Last edited by SenseiTakeshi; 13th March 2016 at 12:25.

Similar Threads

  1. Replies: 3
    Last Post: 5th March 2016, 19:56
  2. Qt Creator Build Qt 4.7.4 using Intel C/C++ compiler, tool chain creation problems
    By napajejenunedk0 in forum Qt Tools
    Replies: 0
    Last Post: 7th September 2011, 00:50
  3. Strange compiler behaviour (compiler passes wrong argument)
    By SasaVilic in forum General Programming
    Replies: 2
    Last Post: 2nd November 2010, 11:36
  4. problems with making cross compiler
    By nataly in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 15th December 2009, 06:44
  5. problems installing open src Qt 4.3.2 on MSVC2005
    By wiseguy in forum Installation and Deployment
    Replies: 10
    Last Post: 17th November 2007, 12:35

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.