mpen
mpen

Reputation: 282875

Qt Widget being resized twice upon initialization?

My "EditorView" (a QGLWidget) is being resized twice when it's created. It starts at say 846x630, then shrinks to 846x607 (losing 23 pixels in height). Created like this:

EditorWindow::EditorWindow() {
    Q_INIT_RESOURCE(icons);

    readSettings();

    setWindowTitle("Q2D Map Editor");

    createActions();
    createMenus();
    createToolBars();
    createStatusBar();

    editorView = new EditorView;
    setCentralWidget(editorView);
}

And then this automatically gets called twice:

void EditorView::resizeGL(int w, int h) {
    printf("%d x %d\n", w, h);
    glViewport(0, 0, w, h);
    updateView();
}

I figure 23 pixels is about the size of the status bar, but the status bar should be already in place before the central widget is initialized, no? Or is it delayed for some reason?


Callstack 1

http://img259.imageshack.us/img259/8881/callstack1.png

Callstack 2

http://img259.imageshack.us/img259/2200/callstack2.png

Upvotes: 0

Views: 321

Answers (1)

Cătălin Pitiș
Cătălin Pitiș

Reputation: 14341

You should set a breakpoint in the resizeGL method, and check the call stack, to see, in both cases, what was the reason for calling resizeGL. From code you provided, it is not obvious.

Upvotes: 3

Related Questions