Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Learning
  3. Qt in Education
  4. QtStringList is not a type error even when "Qt.labs.qmlmodels 1.0" is imported
Forum Updated to NodeBB v4.3 + New Features

QtStringList is not a type error even when "Qt.labs.qmlmodels 1.0" is imported

Scheduled Pinned Locked Moved Unsolved Qt in Education
4 Posts 3 Posters 688 Views 1 Watching
  • 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.
  • Z Offline
    Z Offline
    ZeeoTwo
    wrote on 23 Apr 2023, 13:09 last edited by ZeeoTwo
    #1

    Hello when im trying to use QstringList in this code:

    property QStringList days: []
    Component.onCompleted: {
    	var currentDate = new Date()
    		for (var i = 0; i < 7; i++) {
    		var date = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() + i)
    		var day = ("0" + date.getDate()).slice(-2)
    		var month = ("0" + (date.getMonth() + 1)).slice(-2)
    		var dateString = day + "/" + month
    		days.push(dateString)
    }
    // console.log("Days array:", days)
    

    i get
    8d286b4e-d0ca-4e2b-b36c-a1b385afc796-image.png
    even when:
    import Qt.labs.qmlmodels 1.0
    is present on top of my file

    how can i fix this problem?
    do i need to add anything in my qt project?
    4baa931c-b0cd-4a74-bf04-0bf10f543abc-image.png
    those are my qt modules
    im using qt 6.4.0

    Z T 2 Replies Last reply 23 Apr 2023, 13:22
    0
    • Z ZeeoTwo
      23 Apr 2023, 13:09

      Hello when im trying to use QstringList in this code:

      property QStringList days: []
      Component.onCompleted: {
      	var currentDate = new Date()
      		for (var i = 0; i < 7; i++) {
      		var date = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() + i)
      		var day = ("0" + date.getDate()).slice(-2)
      		var month = ("0" + (date.getMonth() + 1)).slice(-2)
      		var dateString = day + "/" + month
      		days.push(dateString)
      }
      // console.log("Days array:", days)
      

      i get
      8d286b4e-d0ca-4e2b-b36c-a1b385afc796-image.png
      even when:
      import Qt.labs.qmlmodels 1.0
      is present on top of my file

      how can i fix this problem?
      do i need to add anything in my qt project?
      4baa931c-b0cd-4a74-bf04-0bf10f543abc-image.png
      those are my qt modules
      im using qt 6.4.0

      Z Offline
      Z Offline
      ZeeoTwo
      wrote on 23 Apr 2023, 13:22 last edited by
      #2

      @ZeeoTwo From further research i found that properties have basic types
      Link

      i need to use this days arrat inside:

      axisX: BarCategoryAxis {
      	id: categoryAxis
      	categories: days
      }
      

      but the type that categories supports is QStringList
      how can i convert it or just make it work?

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Paul Colby
        wrote on 24 Apr 2023, 00:59 last edited by
        #3

        Hi @ZeeoTwo,

        those are my qt modules

        I know very little about QML, but it might be because QStringList is part of Qt Core, which you don't seem to have selected in your Qt Modules?

        Cheers.

        1 Reply Last reply
        0
        • Z ZeeoTwo
          23 Apr 2023, 13:09

          Hello when im trying to use QstringList in this code:

          property QStringList days: []
          Component.onCompleted: {
          	var currentDate = new Date()
          		for (var i = 0; i < 7; i++) {
          		var date = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() + i)
          		var day = ("0" + date.getDate()).slice(-2)
          		var month = ("0" + (date.getMonth() + 1)).slice(-2)
          		var dateString = day + "/" + month
          		days.push(dateString)
          }
          // console.log("Days array:", days)
          

          i get
          8d286b4e-d0ca-4e2b-b36c-a1b385afc796-image.png
          even when:
          import Qt.labs.qmlmodels 1.0
          is present on top of my file

          how can i fix this problem?
          do i need to add anything in my qt project?
          4baa931c-b0cd-4a74-bf04-0bf10f543abc-image.png
          those are my qt modules
          im using qt 6.4.0

          T Offline
          T Offline
          TomZ
          wrote on 24 Apr 2023, 09:05 last edited by
          #4

          @ZeeoTwo said in QtStringList is not a type error even when "Qt.labs.qmlmodels 1.0" is imported:

          how can i fix this problem?

          QStringList is a C++ class.

          You are writing a QML file which is JavaScript.

          Check there for the full list of QML types:

          https://doc.qt.io/qt-6/qtqml-typesystem-valuetypes.html

          1 Reply Last reply
          0

          1/4

          23 Apr 2023, 13:09

          • Login

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