Tool bar in Qt Design Studio



  • Hi
    I am evaluating the latest Qt Design Studio and wanted to add a tool bar to my newly created project
    When the project is first created Design Studio creates 2 files
    Test.qml

    import QtQuick 2.10
    import Test 1.0
    
    Item {
        width: Constants.width
        height: Constants.height
    
        Screen01 {
        }
    }
    

    and Screen0.ui.qml

    import QtQuick 2.10
    import Test 1.0
    
    Rectangle {
        width: Constants.width
        height: Constants.height
    
        color: Constants.backgroundColor
    
        Text {
            text: qsTr("Hello Test")
            anchors.centerIn: parent
            font: Constants.font
        }
    }
    
    

    When I try to add a toolbar I did this

    import QtQuick 2.10
    import Test 1.0
    import QtQuick.Controls 2.3
    import QtQuick.Layouts 1.3
    
    Item {
        width: Constants.width
        height: Constants.height
    
        ToolBar
        {
            RowLayout
            {
                anchors.fill: parent
                ToolButton
                {
                    text: "xx"
                }
            }
        }
    
        Screen01 {
        }
    }
    
    

    The code compiles and executes but when it runs the tool bar is not displayed

    What am I missing?



  • So i'm not entirely sure what you are trying to do, however i can confirm that Toolbar itself works.

    I used the code you provided here, just removed the instance of Screen01 so i could test the Toolbar item by itself, as you can see it loads in the live preview fine.

    0_1546851760213_toolbar_small.jpg

    You can also check the Application Output (seen here at the bottom of the screen) to look for any errors in your file.

    Best,

    Brook.


Log in to reply
 

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