How to set background of QToolBar's Dockarea in QMainWindow Mac OS?



  • I used below QSS to my app.

    QWidget {
        background:white;
    }
    
    QToolBar {
        spacing: 0px;
    }
    
    QToolBar::handle {
        background: white;
    }
    
    QDockWidget {
        background: white;
    }
    

    I want to set the whole toolbar's background white. But, has failed. like :

    0_1514451865720_QQ20171228-154247.png

    Thank u.


  • Qt Champions 2017

    hi
    image is not showing :)
    alt text



  • @mrjj

    i upload my image again.


  • Qt Champions 2017

    Hi
    Do you have other stylesheets active ?
    Seems to color all of it on default gui project

    alt text



  • @mrjj

    This QToolBar in Mac OS. I also test it in Win, it is Ok.

    But, It has failed, In Mac. In Mac, The gray area is toolbar dock area in mainwindow.

    All the QSS at here

    QWidget {
        background:white;
    }
    
    QToolBar {
        spacing: 0px;
    }
    
    QToolBar::handle {
        background: white;
    }
    
    QDockWidget {
        background: white;
    }
    

  • Qt Champions 2017

    Ah
    so it does so on mac only.
    You are using the normal toolbar and not QMacToolBar ?
    sorry have no mac to test with. Its a bit odd its not affected by "Qwidget"



  • @mrjj oh, QMacToolBar ? Ok, I know where i wrong. Thank u.

    I will modify my code to use QMacToolBar.



  • @joeQ

    About this question. Because I used QToolBar in Mac. It was not good way.

    In Mac, should using QMacToolBar. But, In Windows, you need to use QToolBar.

    So,In the one Qt project, You should use Q_OS_Mac and Q_OS_Win macro to write code in different OS. I think it's not one good way.

    It just one ToolBar, include some ToolButtons. That's all. So, The best way is to using QWidget as ToolBar, add some ToolButtons in QWidget. and do not forget to remove mainToolBar from QMainWindow.


Log in to reply
 

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