Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27

Thread: Qt questions

  1. #21
    Join Date
    Jun 2008
    Location
    Belgrade, Serbia
    Posts
    719

    Default Re: Qt questions

    Thank you Monex, I will try... If I fail... well, Windows users should BUY something else to resize images. They are alergic, by default, to opensource anyways.
    Emil Beli
    http://www.beli.ws/blog/
    openSUSE 11.4 x64 KDE, ATI 5600, i7 dell inspire laptop

  2. #22
    Join Date
    Jun 2008
    Location
    Belgrade, Serbia
    Posts
    719

    Default Re: Qt questions

    Another question, about saving settins.
    So far, I have use QSettings class, and it is good for general settings.

    Now, I will have a collection of profiles where each have collection of settings.

    What is the best way to save it?
    Emil Beli
    http://www.beli.ws/blog/
    openSUSE 11.4 x64 KDE, ATI 5600, i7 dell inspire laptop

  3. #23
    Join Date
    Jun 2008
    Location
    Germany
    Posts
    301

    Default Re: Qt questions

    Hi,

    you can use QSettings and different groups and subgroups. If this is not sufficient maybe you want to store your data in a QDataStream Qt 4.6: QDataStream Class Reference.

    Hope this helps

  4. #24
    Join Date
    Jun 2008
    Location
    Belgrade, Serbia
    Posts
    719

    Default Re: Qt questions

    Yap, thanks.

    I will probably use groups and subgroups...
    Idea is for user to create profiles, each profile will have it's settings, so I want to get:
    1. list of profiles (which can be done with childGroups) and
    2. get settings for the selected profile..

    Should be straight-forward, lets see how it will go when I start doing it actually...
    Emil Beli
    http://www.beli.ws/blog/
    openSUSE 11.4 x64 KDE, ATI 5600, i7 dell inspire laptop

  5. #25
    Join Date
    Jun 2008
    Location
    Belgrade, Serbia
    Posts
    719

    Default Re: Qt questions

    New question:

    I have list of files which I want to process, 1st with mencoder and then with ffmpeg. First with one, then another.

    How do I execute external application and wait for it to finish processing so I can execute again or another app?

    Example that I would do in shell:

    1st pass - join files:
    mencoder FILE1.MPG FILE2.MPG -ovc copy -oac copy -of mpeg -o output.mpg

    2nd pass - convert:
    ffmpeg -i output.mpg -b 2048k -f mp4 FINAL.MPG

    how to do it in Qt4 (execution of external app with wait)?
    Emil Beli
    http://www.beli.ws/blog/
    openSUSE 11.4 x64 KDE, ATI 5600, i7 dell inspire laptop

  6. #26

    Default Re: Qt questions

    Qt Example 1:

    Code:
    #include <qapplication.h>
    #include <qprocess.h>
    #include <qstringlist.h>
    
    int main(int argc,char* argv[])
    {
    	QApplication myApplication(argc,argv);
    
    	// Set up the command line which starts the external program as QStringList.
    	QStringList commandAndParameters;
    
    	/* Fill in the following things:
    	 * - Name of program to execute.
    	 * - Every option needed by the program.
    	 * Attention: be aware of any strange options you pass to the program, e.g.
    	 * IP addresses. Quoting these options will usually help.
    	 */
    	commandAndParameters<<"konqueror"
    				     <<"file:/home/thomas";
    
    	/* Create a QProcess instance. It does not matter if it is created on the stack or
    	 * on the heap. - Ahem, I tested it on Linux only. :-)
    	 */
    	QProcess myProcess(commandAndParameters);
    
    	// Start the QProcess instance.
    	myProcess.start();
    
    	/* O.k., everything is fine now, leave the Qt application. The external program
    	 * will continue running.
    	 */
    	return 0;
    }
    Qt Example 2 - Capturing output:

    mainwindow.h

    Code:
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QtGui/QMainWindow>
    #include <QProcess>
    #include <QMessageBox>
    
    namespace Ui
    {
    	class MainWindowClass;
    }
    
    class MainWindow : public QMainWindow
    {
    	Q_OBJECT
    
    public:
    	MainWindow(QWidget *parent = 0);
    	~MainWindow();
    
    private:
    	Ui::MainWindowClass *ui;
    	QProcess ps;
    	QString output;
    
    private slots:
    	void on_pushButton_exec_clicked();
    
    	void on_cmdExec_finish(int);
    	void on_cmdExec_data_available();
    };
    
    #endif // MAINWINDOW_H

    mainwindow.cpp
    Code:
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindowClass) {
    ui->setupUi(this);
    
    //////// connect signals
    ps.setProcessChannelMode(QProcess::MergedChannels);
    connect(&ps, SIGNAL(readyRead()), this, SLOT(on_cmdExec_data_available()));
    connect(&ps, SIGNAL(finished(int)), this, SLOT(on_cmdExec_finish(int)));
    ////////////////////////
    }
    
    MainWindow::~MainWindow() {
    delete ui;
    }
    
    void MainWindow::on_pushButton_exec_clicked() {
    ui->pushButton_exec->setDisabled(true);
    output = "";
    ps.start(ui->lineEdit_cmd->text(), ui->lineEdit_params->text().split(" "));
    }
    
    void MainWindow::on_cmdExec_finish(int) {
    ui->textEdit_output->append(output);
    ui->pushButton_exec->setEnabled(true);
    }
    
    void MainWindow::on_cmdExec_data_available() {
    output += ps.readAll() + "\n";
    }
    In addition to using QProcess you can also use plain c++ by using the system function. To use the system( )function, which is declared in the header file <cstdlib>:, you give it a character array that you would normally type at the operating system command prompt. This can also include command-line arguments, and the character array can be one that you fabricate at run time (instead of just using a static character array as shown below). The command executes and control returns to the program.

    Code:
    #include <cstdlib> // Declare "system()"
    using namespace std;
    int main() {
    system("Hello");
    } ///:~

  7. #27
    Join Date
    Jun 2008
    Location
    Belgrade, Serbia
    Posts
    719

    Default Re: Qt questions

    Yes, this is exactly what I need. Thank you!
    Emil Beli
    http://www.beli.ws/blog/
    openSUSE 11.4 x64 KDE, ATI 5600, i7 dell inspire laptop

Page 3 of 3 FirstFirst 123

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •