Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple prompt on resize #445

Open
redtide opened this issue Sep 17, 2021 · 8 comments
Open

Multiple prompt on resize #445

redtide opened this issue Sep 17, 2021 · 8 comments
Labels

Comments

@redtide
Copy link

redtide commented Sep 17, 2021

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
@yan12125
Copy link
Member

Mind to share example code for this issue?

@redtide
Copy link
Author

redtide commented Sep 26, 2021

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);
    // ...
}

@yan12125
Copy link
Member

I didn't get duplicated prompts with such a layout. Could you paste a complete example? (ex: main.cpp that can be directly compiled)

@redtide
Copy link
Author

redtide commented Sep 26, 2021

#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"

@yan12125
Copy link
Member

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"

@yan12125 yan12125 added the bug label Sep 27, 2021
@redtide
Copy link
Author

redtide commented Sep 27, 2021

uhm, I tried to change the shell to zsh using a similar code but it still use bash (zsh is installed and working).

@yan12125
Copy link
Member

Did you set startnow=0 for QTermWidget's constructor like this?

, terminal(new QTermWidget(0, spltVertical))

@redtide
Copy link
Author

redtide commented Sep 27, 2021

Ah nope, I didn't notice that, that worked, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants