Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML not displaying correctly

QML not displaying correctly

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 782 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    clarity
    wrote on last edited by
    #1

    Hey,

    I'm using the Tabs component. The first tab (Blocks) displays correctly, but when I navigate to the Transactions tabs, the TextArea goes off the screen.

    Here's the code:
    import QtQuick 2.5
    import QtQuick.Controls 1.4
    import QtQuick.Layouts 1.2
    import QtQuick.Dialogs 1.2

    ApplicationWindow {
    id: mainWindow
    visible: true
    width: 640
    height: 480
    title: qsTr("Block Explorer")

    signal prevPressed();
    signal nextPressed();
    
    menuBar: MenuBar {
        Menu {
            title: qsTr("File")
            MenuItem {
                text: qsTr("&Open")
                onTriggered: console.log("Open action triggered");
            }
            MenuItem {
                text: qsTr("Exit")
                onTriggered: Qt.quit();
            }
        }
    }
    
    
    TabView {
        anchors.fill: parent
    
        Tab {
            title: "Blocks"
            Item {
                anchors.centerIn: parent
    
                TextArea {
                    id: block
                    x: 107
                    y: 62
                    width: 392
                    height: 327
                    visible: true
                    frameVisible: true
                    tabChangesFocus: false
                    readOnly: true
                    text: Test.text
                }
    
                Button {
                    id: previous
                    x: 240
                    y: 400
                    onClicked: mainWindow.prevPressed()
                    text: qsTr("Previous")
                }
    
                Button {
                    id: next
                    x: 340
                    y: 400
                    onClicked: mainWindow.nextPressed()
                    text: qsTr("Next")
                }
    
            }
        }
        Tab {
            title: "Transactions"
            anchors.centerIn: parent
    
            TextArea {
                id: transactions
                x: 107
                y: 62
                width: 392
                height: 327
                visible: true
                frameVisible: true
                tabChangesFocus: false
                readOnly: true
                text: "Transactions"
            }
    
            Button {
                id: transaction_previous
                x: 240
                y: 400
                onClicked: mainWindow.prevPressed()
                text: qsTr("Previous")
            }
    
            Button {
                id: transaction_next
                x: 340
                y: 400
                onClicked: mainWindow.nextPressed()
                text: qsTr("Next")
            }
        }
        Tab {
            title: "State"
            anchors.centerIn: parent
    
            Rectangle {
                color: "green"
            }
        }
    }
    
    MessageDialog {
        id: messageDialog
        title: qsTr("May I have your attention, please?")
    
        function show(caption) {
            messageDialog.text = caption;
            messageDialog.open();
        }
    }
    

    }

    1 Reply Last reply
    0
    • C Offline
      C Offline
      clarity
      wrote on last edited by
      #2

      Whoops, forgot to put the second tab in an Item

      Here's the fixed code:
      import QtQuick 2.5
      import QtQuick.Controls 1.4
      import QtQuick.Layouts 1.2
      import QtQuick.Dialogs 1.2

      ApplicationWindow {
      id: mainWindow
      visible: true
      width: 640
      height: 480
      title: qsTr("Block Explorer")

      signal prevPressed();
      signal nextPressed();
      
      menuBar: MenuBar {
          Menu {
              title: qsTr("File")
              MenuItem {
                  text: qsTr("&Open")
                  onTriggered: console.log("Open action triggered");
              }
              MenuItem {
                  text: qsTr("Exit")
                  onTriggered: Qt.quit();
              }
          }
      }
      
      
      TabView {
          anchors.fill: parent
      
          Tab {
              title: "Blocks"
              Item {
                  anchors.centerIn: parent
      
                  TextArea {
                      id: block
                      x: 107
                      y: 62
                      width: 392
                      height: 327
                      visible: true
                      frameVisible: true
                      tabChangesFocus: false
                      readOnly: true
                      text: Test.text
                  }
      
                  Button {
                      id: previous
                      x: 240
                      y: 400
                      onClicked: mainWindow.prevPressed()
                      text: qsTr("Previous")
                  }
      
                  Button {
                      id: next
                      x: 340
                      y: 400
                      onClicked: mainWindow.nextPressed()
                      text: qsTr("Next")
                  }
      
              }
          }
          Tab {
              title: "Transactions"
              Item {
                  anchors.centerIn: parent
      
                  TextArea {
                      id: transactions
                      x: 107
                      y: 62
                      width: 392
                      height: 327
                      visible: true
                      frameVisible: true
                      tabChangesFocus: false
                      readOnly: true
                      text: "Transactions"
                  }
      
                  Button {
                      id: transaction_previous
                      x: 240
                      y: 400
                      onClicked: mainWindow.prevPressed()
                      text: qsTr("Previous")
                  }
      
                  Button {
                      id: transaction_next
                      x: 340
                      y: 400
                      onClicked: mainWindow.nextPressed()
                      text: qsTr("Next")
                  }
              }
          }
          Tab {
              title: "State"
              anchors.centerIn: parent
      
              Rectangle {
                  color: "green"
              }
          }
      }
      
      MessageDialog {
          id: messageDialog
          title: qsTr("May I have your attention, please?")
      
          function show(caption) {
              messageDialog.text = caption;
              messageDialog.open();
          }
      }
      

      }

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved