Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QDockWidget problem with focus when undocked



  • Hi,

    I have a QDockWidget with some other QWidgets inside (QTreeView with Delegates)

    Now when I undock it and than try to edit a entry of the QTreeView by clicking a cell, the cursor appears in the cell, however than the focus of the window jumps to the MainWindow (Title bar gets highlighted as if it is in the front) and i cannot edit the entry.

    This only happens sometimes (docking and undocking allows turning the problem on and off) and I have no clue on how to debug it.

    Any ideas what the reason could be??

    Qt Version is 5.11 on Debian Strech

    EDIT: I just found out that the focus also jumps back to the MainWindow when I do not try to edit anything, but just click the titlebar or anywhere else on the QDockWidget.


  • Lifetime Qt Champion

    HI,

    How did you install Qt ?
    Do you have the same behaviour with the distribution provided Qt ?



  • I've installed it over the Qt-Installer / Maintenance Tool.
    When I use the Qt version shipped with the distribution (5.7.1) i get the same behavior.

    EDIT: I have set up a new Project just with the Qt-Designer

    • New Qt Widget Application
    • Add a Dock Widgets (with Designer or by code)
    • Run
      -> Same problem there

    This the mainwindwo.cpp

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QDockWidget>
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
        QDockWidget *dock = new QDockWidget(tr("Test"), this);
        dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
        QWidget *wi = new QWidget(this);
        dock->setWidget(wi);
        addDockWidget(Qt::RightDockWidgetArea, dock);
    
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    

    Or this is the second thing i tried with the Designer. Same problem
    This is the Qt-Designer ui file

    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>MainWindow</class>
     <widget class="QMainWindow" name="MainWindow">
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>400</width>
        <height>300</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>MainWindow</string>
      </property>
      <widget class="QWidget" name="centralWidget"/>
      <widget class="QMenuBar" name="menuBar">
       <property name="geometry">
        <rect>
         <x>0</x>
         <y>0</y>
         <width>400</width>
         <height>19</height>
        </rect>
       </property>
      </widget>
      <widget class="QToolBar" name="mainToolBar">
       <attribute name="toolBarArea">
        <enum>TopToolBarArea</enum>
       </attribute>
       <attribute name="toolBarBreak">
        <bool>false</bool>
       </attribute>
      </widget>
      <widget class="QStatusBar" name="statusBar"/>
      <widget class="QDockWidget" name="dockWidget_3">
       <attribute name="dockWidgetArea">
        <number>1</number>
       </attribute>
       <widget class="QWidget" name="dockWidgetContents_3"/>
      </widget>
     </widget>
     <layoutdefault spacing="6" margin="11"/>
     <resources/>
     <connections/>
    </ui>
    
    

  • Lifetime Qt Champion

    What desktop environment are you using ?



  • The desktop environment is KDE (under Debian)
    I've tested it on Windows 7 today, there the problem does not occur.


  • Lifetime Qt Champion

    What version of Qt for Windows ?



  • On Widows it's also Qt 5.11 which is the same as on the Debian machine (also installed over the Qt-Installer)


Log in to reply