Multiple prompt on resize
redtide opened this issue · 8 comments
When resizing a main window containing a QTermWidget inside a splitter the prompt gets "repeated" multiple times. Like:
[redtide@pc] 10:30 $
[redtide@pc] 10:30 $
[redtide@pc] 10:30 $
Expected Behavior
The widgets resize with the parent window and the original prompt is shown, like normally happens with QTerminal.
Current Behavior
See above.
Context
I'm writing a simple editor with a QTreeView on the left, then a QTabWidget and a QTermWidget on the right.
The QTabWidget and QTermWidget are inside a vertical splitter, the QTreeView and the vertical splitter are inside a
horizontal splitter.
The issue happens also when not resizing the main window but just moving the splitters.
System Information
- Distribution & Version: Archlinux
- Kernel: 5.13.13
- Qt Version: 5.15.2
- lxqt-build-tools Version: 0.9.0-1
- Package version: 0.17.0-2
Mind to share example code for this issue?
Oh, sure, here it is: other than the widgets described above there is a central widget and vbox layout.
MainWindow::MainWindow()
: QMainWindow()
, wgtMain(new QWidget(this))
, layout(new QVBoxLayout(wgtMain))
, spltMain(new QSplitter(Qt::Horizontal, wgtMain))
, fileManager(new QTreeView(spltMain))
, fileManagerModel(new QFileSystemModel)
, spltVertical(new QSplitter(Qt::Vertical, spltMain))
, tabWidget(new QTabWidget(spltVertical))
, terminal(new QTermWidget(spltVertical))
{
// ...
terminal->setScrollBarPosition(QTermWidget::ScrollBarRight);
terminal->setColorScheme("GreenOnBlack");
terminal->changeDir(currentDirectory);
terminal->setTerminalSizeHint(false);
// ...
}
I didn't get duplicated prompts with such a layout. Could you paste a complete example? (ex: main.cpp that can be directly compiled)
#include <QApplication>
#include <QFileSystemModel>
#include <QHeaderView>
#include <QMainWindow>
#include <QSplitter>
#include <QStackedWidget>
#include <QTabWidget>
#include <QTreeView>
#include <QVBoxLayout>
#include <qtermwidget5/qtermwidget.h>
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow();
private:
QWidget* wgtMain;
QVBoxLayout* layout;
QSplitter* spltMain;
QTreeView* fileManager;
QFileSystemModel* fileManagerModel;
QSplitter* spltVertical;
QTabWidget* tabWidget;
QTermWidget* terminal;
QString currentDir;
};
MainWindow::MainWindow()
: QMainWindow()
, wgtMain(new QWidget(this))
, layout(new QVBoxLayout(wgtMain))
, spltMain(new QSplitter(Qt::Horizontal, wgtMain))
, fileManager(new QTreeView(spltMain))
, fileManagerModel(new QFileSystemModel)
, spltVertical(new QSplitter(Qt::Vertical, spltMain))
, tabWidget(new QTabWidget(spltVertical))
, terminal(new QTermWidget(spltVertical))
, currentDir(QDir::homePath())
{
layout->addWidget(spltMain);
spltVertical->addWidget(tabWidget);
spltVertical->addWidget(terminal);
fileManagerModel->setRootPath(currentDir);
fileManager->setModel(fileManagerModel);
fileManager->setRootIndex(fileManagerModel->index(currentDir));
fileManager->hideColumn(1);
fileManager->hideColumn(2);
fileManager->hideColumn(3);
fileManager->header()->hide();
terminal->setScrollBarPosition(QTermWidget::ScrollBarRight);
terminal->setColorScheme("GreenOnBlack");
terminal->changeDir(currentDir);
terminal->setTerminalSizeHint(false);
setCentralWidget(wgtMain);
}
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
#include "main.moc"
Thanks, I can reproduce the issue with bash (my default shell is zsh, which seems not affected by this issue). As a record:
#include <QApplication>
#include <QFileSystemModel>
#include <QHeaderView>
#include <QMainWindow>
#include <QSplitter>
#include <QStackedWidget>
#include <QTabWidget>
#include <QTreeView>
#include <QVBoxLayout>
#include <qtermwidget5/qtermwidget.h>
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow();
private:
QWidget* wgtMain;
QVBoxLayout* layout;
QSplitter* spltMain;
QTreeView* fileManager;
QFileSystemModel* fileManagerModel;
QSplitter* spltVertical;
QTabWidget* tabWidget;
QTermWidget* terminal;
QString currentDir;
};
MainWindow::MainWindow()
: QMainWindow()
, wgtMain(new QWidget(this))
, layout(new QVBoxLayout(wgtMain))
, spltMain(new QSplitter(Qt::Horizontal, wgtMain))
, fileManager(new QTreeView(spltMain))
, fileManagerModel(new QFileSystemModel)
, spltVertical(new QSplitter(Qt::Vertical, spltMain))
, tabWidget(new QTabWidget(spltVertical))
, terminal(new QTermWidget(0, spltVertical))
, currentDir(QDir::homePath())
{
layout->addWidget(spltMain);
spltVertical->addWidget(tabWidget);
spltVertical->addWidget(terminal);
fileManagerModel->setRootPath(currentDir);
fileManager->setModel(fileManagerModel);
fileManager->setRootIndex(fileManagerModel->index(currentDir));
fileManager->hideColumn(1);
fileManager->hideColumn(2);
fileManager->hideColumn(3);
fileManager->header()->hide();
terminal->setScrollBarPosition(QTermWidget::ScrollBarRight);
terminal->setColorScheme("GreenOnBlack");
terminal->changeDir(currentDir);
terminal->setTerminalSizeHint(false);
terminal->setShellProgram("/bin/bash");
terminal->startShellProgram();
setCentralWidget(wgtMain);
}
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
#include "main.moc"
uhm, I tried to change the shell to zsh
using a similar code but it still use bash
(zsh is installed and working).
Did you set startnow=0 for QTermWidget's constructor like this?
, terminal(new QTermWidget(0, spltVertical))
Ah nope, I didn't notice that, that worked, thank you.