PDA

View Full Version : QMainWindow::addDockWidget: invalid 'area' argument



Yuri20
4th December 2014, 23:31
I have quick implementation of QMainWindow based on *.ui generated design.


#include <QWidget>
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <iostream>

MainWindow::MainWindow(QWidget* parent){
m_parent = parent;
m_ui = new Ui::MainWindow;
m_ui->setupUi(this);
QObject::connect(m_ui->actionDodaj, SIGNAL(triggered()), SLOT(gupota()));
}

void MainWindow::gupota(){
create_dock();
}

void MainWindow::create_dock(){
QDockWidget* dock = new QDockWidget(this);
dock->setAllowedAreas(Qt::AllDockWidgetAreas);
this->addDockWidget(Qt::AllDockWidgetAreas, dock);
}

After creating new QDockWidget in create_dock() Qt returns to console


QMainWindow::addDockWidget: invalid 'area' argument

If I change Qt::AllDockWidgetAreas to for example Qt::LeftDockWidgetArea (or anything else except Qt::AllDockWidgetAreas) everything works fine. Why is that? I want to be able to move QDockWidget everywhere I want to, not only to the left or right or top or bottom...

anda_skoa
5th December 2014, 08:10
Consider for a moment what the name of the method is.

Then consider that a widget can only be at one place at any given time.

Cheers,
_

Yuri20
5th December 2014, 14:00
Ok, I understand that QDockWidget cannot be added to all sides at the same time :P But why I cannot move QDockWidget to for example right side of QMainWindow when it was attached at first to the left side?

anda_skoa
5th December 2014, 16:26
That should work indeed.

Both the default for allowed areas (all) as well as features (movable) are OK with that.

Are you asking for a user triggered move or doing it programmatically?

Cheers,
_