I have created a simple reproducer. Actually I've left almost all the code unchanged except for a couple of functions and MainWindow::MainWindow, which is now a few lines:
MainWindow
::MainWindow(QWidget *parent
){
setupUi(this);
showMaximized();
connect(action_run, SIGNAL(triggered()), SLOT(runServer()));
goToInputs();
}
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setupUi(this);
showMaximized();
connect(action_run, SIGNAL(triggered()), SLOT(runServer()));
goToInputs();
}
To copy to clipboard, switch view to plain text mode
After goToInputs() has executed, clicking the Run button executes runServer():
void MainWindow::runServer()
{
initializer();
goToOutputs();
return;
}
void MainWindow::initializer()
{
bool use_graphs = true;
mdiArea = new QMdiArea;
for (int i = 0; i < 20; i++) {
if (use_graphs) {
pGraph[i] = new Plot("tag","title");
mdiArea->addSubWindow(pGraph[i]);
} else {
editor[i]->setMinimumHeight(200);
editor[i]->setMinimumWidth(80);
mdiArea->addSubWindow(editor[i]);
}
}
verticalLayout_3->addWidget(mdiArea,2);
verticalLayout_3->addWidget(box_outputLog,1);
mdiArea->tileSubWindows();
for (int i = 0; i < 50; i++) {
box_outputLog->append(line);
}
}
void MainWindow::runServer()
{
initializer();
goToOutputs();
return;
}
void MainWindow::initializer()
{
bool use_graphs = true;
mdiArea = new QMdiArea;
box_outputLog = new QTextBrowser;
for (int i = 0; i < 20; i++) {
if (use_graphs) {
pGraph[i] = new Plot("tag","title");
mdiArea->addSubWindow(pGraph[i]);
} else {
editor[i] = new QTextEdit;
editor[i]->setMinimumHeight(200);
editor[i]->setMinimumWidth(80);
mdiArea->addSubWindow(editor[i]);
}
}
verticalLayout_3->addWidget(mdiArea,2);
verticalLayout_3->addWidget(box_outputLog,1);
mdiArea->tileSubWindows();
for (int i = 0; i < 50; i++) {
QString line = "line number: " + QString::number(i);
box_outputLog->append(line);
}
}
To copy to clipboard, switch view to plain text mode
With use_graphs = true or false, I get the attached with-QwtPlot.jpg or with-QTextEdit.jpg, attached.
Here is class Plot:
{
public:
~Plot();
void removeAllCurves();
void redraw2(double *, double *, double *, double *, int, int);
void draw2(double *, double *, double *, double *, int, int);
void setYScale(double);
double calc_yscale(double);
static const int ncmax = 8;
double xscale;
double yscale;
int ncurves;
char msg[1024];
};
class Plot : public QwtPlot
{
public:
Plot(QString, QString, QWidget *parent = 0);
~Plot();
void mousePressEvent (QMouseEvent *);
void addCurve(QString);
void removeCurve(QString);
void removeAllCurves();
void redraw(double *, double *, int, QString, QString, double, bool);
void redraw2(double *, double *, double *, double *, int, int);
void draw2(double *, double *, double *, double *, int, int);
void setYScale(double);
double calc_yscale(double);
QString name;
static const int ncmax = 8;
QwtPlotCurve *curve[ncmax];
double xscale;
double yscale;
int ncurves;
char msg[1024];
};
To copy to clipboard, switch view to plain text mode
(I am using qwt-6.1.3)
mainwindow.h includes:
QMdiArea *mdiArea;
Plot *pGraph[32];
QMdiArea *mdiArea;
QTextBrowser *box_outputLog;
QTextEdit *editor[20];
Plot *pGraph[32];
To copy to clipboard, switch view to plain text mode
page_output looks similar but not quite the same in the two cases. With use_graphs=false (with-QTextEdit.jpg) the scrollbar enables viewing of lines 1 to 35 - the last 14 lines are off the screen. With use_graphs=true (with-QwtPlot), there is a scrollbar on the text window, but the slider is not visible, and only lines 13 to 18 can be seen. In both cases the MDI window scrolls correctly, but the window sizing is different in the two cases, and in neither does it correspond to the 2:1 ratio specified by the stretch factors.
I have made a closeup pic of the relevant section of the UI display (ui-closeup.jpg), showing where verticalLayout_3 is located.
Edit: A small correction: the scrollbar slider for the use_graphs=true case can be raised by clicking in the bar, but only 6 lines can ever be viewed, e.g. lines 0-5. It's possible that, taking into account that part of the layout that is invisible (off-screen), the 2:1 ratio is in fact effective. The question is this: how to make the layout fit the screen?
Bookmarks