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
QtWS25 Last Chance

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 673 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.
  • Z Offline
    Z Offline
    ZeeoTwo
    wrote on 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 TomZT 2 Replies Last reply
    0
    • Z ZeeoTwo

      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 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
      • Paul ColbyP Offline
        Paul ColbyP Offline
        Paul Colby
        wrote on 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

          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

          TomZT Offline
          TomZT Offline
          TomZ
          wrote on 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

          • Login

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