This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to setup environment for a konsolepart?

Tags: None
(comma "," separated)
Aequitas
Registered Member
Posts
1
Karma
0
Hello,

I am new to KDE and I am working a project where I would like to embed konsole into my application. I found examples online and I have successfully embedded konsole into my application using the code below. I am know trying to figure out how to change the working directory (without error message) and set the environment, any guidance would be greatly appreciated.

Code: Select all
#include "mainwindow.h"

#include <kde_terminal_interface.h>
#include <kservice.h>
#include <QTabWidget>
#include <QMessageBox>
#include <QDebug>

MainWindow::MainWindow()
{
  QTabWidget *tabwidget = new QTabWidget;
  setCentralWidget(tabwidget);

  KService::Ptr service = KService::serviceByDesktopName("konsolepart");
  if (!service)
  {
    QMessageBox::critical(this, tr("Konsole not installed"), tr("Please install the kde konsole and try again!"), QMessageBox::Ok);
    return ;
  }

  // create one instance of konsolepart
  m_part = service->createInstance<KParts::ReadOnlyPart>(this, tabwidget, QVariantList());
  if (!m_part)
    return;


  // start the terminal in directory
  // The command below creates the error message: Konsole::Session::run: Attempted to re-run an already running session.
  qobject_cast<TerminalInterface*>(m_part)->showShellInDir(QLatin1String("/home/ros/catkin_abb_ws") );

  tabwidget->addTab(m_part->widget(), "test");
}


Regards,

Levi


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]