Столкнулся со странной проблемой, объявленная переменная из одной функции доступна, из другой нет. Чтоб было понятно, что и как, листинг ниже:
mainwindow.cppC++ (Qt)
#include "mainwindow.h"
#include "ui_mainwindow.h"
 
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
{
    term_command = new QProcess(this);
    term_command->setProcessChannelMode(QProcess::MergedChannels);
    connect(term_command, SIGNAL(readyReadStandardOutput()), SLOT(command_process()));
    connect(term_command, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(exitProcess()));
    ui->setupUi(this);
    sent();
    save();
}
 
MainWindow::~MainWindow()
{
    delete ui;
}
 
void MainWindow::command_process()
{
   term_command->start(process);
   output = term_command->readAllStandardOutput();
   ui->textEdit->insertPlainText(output); //Output
 
}
void MainWindow::sent()
{
   process="uname";
   command_process();
}
 
void MainWindow::save()
{
   ui->textEdit->insertPlainText(output); //No output
   QFile file("./distrib.txt");
   if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
   return;
   QTextStream out(&file);
   out << output;
}
mainwindow.hC++ (Qt)
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
 
#include <QtGui/QMainWindow>
#include <QProcess>
#include <QFile>
#include <QTextStream>
#include <QByteArray>
 
namespace Ui
{
    class MainWindow;
}
 
class MainWindow : public QMainWindow
{
    Q_OBJECT
 
public:
    MainWindow(QWidget *parent = 0);
    QByteArray output;
    QProcess *term_command;
    QString process;
    ~MainWindow();
 
private:
    Ui::MainWindow *ui;
    void save();
    void sent();
 
private slots:
    void command_process();
 
};
 
#endif // MAINWINDOW_H
mainwindow.uiC++ (Qt)
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>600</width>
    <height>400</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralWidget">
   <widget class="QTextEdit" name="textEdit">
    <property name="geometry">
     <rect>
      <x>30</x>
      <y>20</y>
      <width>251</width>
      <height>181</height>
     </rect>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton">
    <property name="geometry">
     <rect>
      <x>100</x>
      <y>220</y>
      <width>92</width>
      <height>28</height>
     </rect>
    </property>
    <property name="text">
     <string>PushButton</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_2">
    <property name="geometry">
     <rect>
      <x>300</x>
      <y>30</y>
      <width>92</width>
      <height>28</height>
     </rect>
    </property>
    <property name="text">
     <string>PushButton</string>
    </property>
   </widget>
  </widget>
  <widget class="QMenuBar" name="menuBar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>600</width>
     <height>25</height>
    </rect>
   </property>
  </widget>
  <widget class="QToolBar" name="mainToolBar">
   <attribute name="toolBarArea">
    <enum>TopToolBarArea</enum>
   </attribute>
   <attribute name="toolBarBreak">
    <bool>false</bool>
   </attribute>
  </widget>
  <widget class="QStatusBar" name="statusBar"/>
 </widget>
 <layoutdefault spacing="6" margin="11"/>
 <resources/>
 <connections/>
</ui>
Как видно из кода, при попытке вывести содержимое output из ф-ции save(), ее содержимое отсуствует, когда как из самой ф-ции command_process оно есть.
В чем тут загвоздка?
Еще странный момент, если изменить строку в ф-ции save() на:
C++ (Qt)
ui->textEdit->insertPlainText(output+"1");
То вывод будет "1Linux". А вот как получается, что это строка вызывается первее, чем раньше вызванная ф-ция я просто не понимаю...