Setting the background-color of separators only works when separators are draggable



  • I have three QDockWidgets on my QMainWindow. I would like to change the color of the separators. I'd also like to make the separators 2 pixels thick so I tried setting the stylesheet of the window to this:

    QMainWindow::separator {
      width: 2px;
      height: 2px;
      background-color: #B8CDD7;
    }
    

    The dock on the bottom of the screen is resizable and the separator has the color correctly applied. The docks on the left and right are not resizable and the separator doesn't have the color applied. The width of the side docks is being set but the background color is the default window background. Maybe the separators are invisible when they aren't draggable? Or perhaps I need to use a selector for non-draggable separators?

    As a quick test, I removed a call to setFixedWidth from one of the side docks and the separator color was correctly applied. This definitely has something to do with the draggability of the separators.


  • Lifetime Qt Champion

    Hi,

    You should also mention:

    • Qt version
    • OS running

    Can you provide a minimal compilable example that shows your situation ?



  • @SGaist Here's an MCVE of the problem:

    #include <QtWidgets/qdockwidget.h>
    #include <QtWidgets/qmainwindow.h>
    #include <QtWidgets/qapplication.h>
    
    void addDock(QMainWindow *window, Qt::DockWidgetArea area, QWidget *widget) {
      QDockWidget *dock = new QDockWidget{window};
      dock->setFeatures(QDockWidget::NoDockWidgetFeatures);
      dock->setAllowedAreas(area);
      dock->setWidget(widget);
      dock->setTitleBarWidget(new QWidget{dock});
      window->addDockWidget(area, dock);
    }
    
    int main(int argc, char **argv) {
      QApplication app{argc, argv};
      QMainWindow window;
      
      window.setStyleSheet(R"(
        QMainWindow::separator {
          width: 10px;
          height: 10px;
          background-color: #F00;
        }
      )");
      
      QWidget bottom{&window};
      bottom.setMinimumHeight(100);
      bottom.setStyleSheet("background-color: #0F0");
      addDock(&window, Qt::BottomDockWidgetArea, &bottom);
      
      QWidget left{&window};
      left.setFixedWidth(100);
      left.setStyleSheet("background-color: #00F");
      addDock(&window, Qt::LeftDockWidgetArea, &left);
      
      QWidget center{&window};
      center.setMinimumSize(300, 300);
      center.setStyleSheet("background-color: #0FF");
      window.setCentralWidget(&center);
      
      window.show();
      
      return app.exec();
    }
    

    This is what I'm seeing:

    Screenshot

    Notice that the separator between the left widget and the central widget is the default window background color (not red).

    I'm using Qt 5.12.3 on macOS 10.14.4



  • Could this be a bug? Maybe I'm just doing something wrong?


  • Lifetime Qt Champion

    I think you have found a bug. Did you already check the bug report system ? If not, please do so and if you find nothing, consider opening a new report providing your example. If there's already a report, update it with the information you currently have.

    I can also confirm this happens on Linux with the current dev branch of qtbase.



  • @SGaist I had a look at the bug tracker and couldn't anything. I'll open a new bug report and post a link here.





  • @SGaist I don't mean to sound impatient but does it usually take this long to get a response on a bug report? I mean, it's been a month and there's been no response. The bug can be reproduced with a 44 line C++ program. I even included screenshots of the expected and actual results.

    Although, this isn't a critical bug. I just have to include an annoying workaround in my application.


  • Moderators

    @Kerndog73
    sadly not uncommon. If it's not a critical bug.

    Take a look at this bugreport

    https://bugreports.qt.io/browse/QTBUG-63157

    created Sep. 2017. The issue is, that no virtual keyboard is shown on iOS if you use QQuickWidget and any Input item.

    One would think this would have somewhat high priority...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.