Results 1 to 4 of 4

Thread: QMainWindow::addDockWidget: invalid 'area' argument

  1. #1

    Default QMainWindow::addDockWidget: invalid 'area' argument

    I have quick implementation of QMainWindow based on *.ui generated design.

    Qt Code:
    1. #include <QWidget>
    2. #include "MainWindow.h"
    3. #include "ui_MainWindow.h"
    4. #include <iostream>
    5.  
    6. MainWindow::MainWindow(QWidget* parent){
    7. m_parent = parent;
    8. m_ui = new Ui::MainWindow;
    9. m_ui->setupUi(this);
    10. QObject::connect(m_ui->actionDodaj, SIGNAL(triggered()), SLOT(gupota()));
    11. }
    12.  
    13. void MainWindow::gupota(){
    14. create_dock();
    15. }
    16.  
    17. void MainWindow::create_dock(){
    18. QDockWidget* dock = new QDockWidget(this);
    19. dock->setAllowedAreas(Qt::AllDockWidgetAreas);
    20. this->addDockWidget(Qt::AllDockWidgetAreas, dock);
    21. }
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. QMainWindow::addDockWidget: invalid 'area' argument
    To copy to clipboard, switch view to plain text mode 

    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...

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow::addDockWidget: invalid 'area' argument

    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,
    _

  3. #3

    Default Re: QMainWindow::addDockWidget: invalid 'area' argument

    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?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow::addDockWidget: invalid 'area' argument

    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,
    _

Similar Threads

  1. Replies: 7
    Last Post: 8th November 2012, 11:26
  2. QMainWindow with fixed area + Dockarea
    By trallallero in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2012, 09:25
  3. Why? Invalid type argument of unary *
    By progman in forum Newbie
    Replies: 4
    Last Post: 21st March 2011, 19:31
  4. Building static Qt. Error 126 invalid argument
    By kea_ in forum Installation and Deployment
    Replies: 2
    Last Post: 20th March 2011, 07:58
  5. GLib-WARNING **: poll(2) failed due to: Invalid argument.
    By December in forum Qt Programming
    Replies: 4
    Last Post: 17th February 2009, 05:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.