PDA

View Full Version : QwtPlot in QTabWidget, then QMainWindow::showMaximized doesn't fill the whole screen?



likeforever
23rd March 2015, 17:05
I put QwtPlot in QTabWidget, then QMainWindow::showMaximized when construct MainWindow doesn't fill the whole screen. although it looks like Maximized by the Maximize button. Is there any way to solve this problem?

anda_skoa
23rd March 2015, 18:54
You'll need to be a bit more forthcoming with details.

Did the main window not show maximized?
Did the tabwidget not fill the window?
Did the plot not fill the tabwidget?

Cheers,
_

likeforever
24th March 2015, 01:17
Thank you for your reply. Details:


MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);

QTabWidget *tw = new QTabWidget();

QwtPlot *pt = new QwtPlot();
tw->insertTab(0, pt, "pt");

QStatusBar *bar = QMainWindow::statusBar();
QLabel *detailLabel = new QLabel("test");
bar->addWidget(detailLabel, 1);

setCentralWidget(tw);


showMaximized();
}

11026

anda_skoa
24th March 2015, 05:53
Do you do anything with the main window instance other than creating it?

Cheers,
_

likeforever
24th March 2015, 06:43
No. I just modified the MainWindow construct method code as above. I use qt 5.4.0.

anda_skoa
24th March 2015, 09:55
Ok, just to verify: you are not calling show() on it in main(), right?

Because that is what gets usually generated by templates.

Cheers,
_

likeforever
24th March 2015, 14:40
I call show() in main as below. To solve the problem, I create new project by templates and only just modify MainWindow::MainWindow.


#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();

return a.exec();
}


Extra information: if not add statusbar, then everything ok. Or not add qwtplot tab, everything is ok too.

anda_skoa
24th March 2015, 16:17
I call show() in main as below.

So let me get this straight:

I asked you if you do anything else with the instance other than creating it.
You said you do not.
Now you say you do.

Why not call showMaximized() instead of hoping that the show() does not change the state you requested inside the window's constructor?
Luck based programming?

Cheers,
_

likeforever
25th March 2015, 02:26
Thank you for your patient answer.
I tried showMaximized inside main() or remove show() in main, but it can't work too.

anda_skoa
25th March 2015, 10:08
Hmm.

Have you tried without the


ui->setupUi(this);


Cheers,
_