Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QList<QPushButton *> to QList<QWidget *> impossible
Qt 6.11 is out! See what's new in the release blog

QList<QPushButton *> to QList<QWidget *> impossible

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 2.1k Views 2 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.
  • A Offline
    A Offline
    Amott
    wrote on last edited by
    #1

    Hello everyone !

    I'm facing a problem with my project :(
    I have a class "ElementArbo" which inherits QPushButton, and in this class I have a member QList<ElementAbo*>.
    I need to send this list to animate my buttons via another class "Animateur" which have 2 methods :

    static void translation(QWidget * const & objet, QPoint posDepart, QPoint posArrivee, int duree);
    static void translationMultiple(QList<QWidget * const> &objets, QList<QPoint> &posDepart, QList<QPoint> &posArrivee, QList<int> &duree);
    

    When I want to do a simple translation and send one element of my list, it works well. But when I send my list it says that "No known conversion for argument 1 from 'QList<ElementArbo*>' to 'QList<QWidget* const>&"
    I have tried a dynamic_cast but it doesn't work.

    If someone has a clue, I'll take it :)

    Thank you !

    kshegunovK 1 Reply Last reply
    0
    • A Amott

      Hello everyone !

      I'm facing a problem with my project :(
      I have a class "ElementArbo" which inherits QPushButton, and in this class I have a member QList<ElementAbo*>.
      I need to send this list to animate my buttons via another class "Animateur" which have 2 methods :

      static void translation(QWidget * const & objet, QPoint posDepart, QPoint posArrivee, int duree);
      static void translationMultiple(QList<QWidget * const> &objets, QList<QPoint> &posDepart, QList<QPoint> &posArrivee, QList<int> &duree);
      

      When I want to do a simple translation and send one element of my list, it works well. But when I send my list it says that "No known conversion for argument 1 from 'QList<ElementArbo*>' to 'QList<QWidget* const>&"
      I have tried a dynamic_cast but it doesn't work.

      If someone has a clue, I'll take it :)

      Thank you !

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @Amott
      Hello,

      I have tried a dynamic_cast but it doesn't work.

      How did you cast it exactly?

      Read and abide by the Qt Code of Conduct

      A 1 Reply Last reply
      0
      • kshegunovK kshegunov

        @Amott
        Hello,

        I have tried a dynamic_cast but it doesn't work.

        How did you cast it exactly?

        A Offline
        A Offline
        Amott
        wrote on last edited by
        #3

        @kshegunov
        Hi kshegunov !

        Here is how I did :

        Animateur::translationMultiple(dynamic_cast<QList<QWidget *>>(listFils), listPtD, listPtA, listDuree);
        
        kshegunovK 1 Reply Last reply
        0
        • A Amott

          @kshegunov
          Hi kshegunov !

          Here is how I did :

          Animateur::translationMultiple(dynamic_cast<QList<QWidget *>>(listFils), listPtD, listPtA, listDuree);
          
          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @Amott
          Hi!
          This will not work.QList<QWidget *> and QList<ElementArbo*> are two completely different (and unrelated classes) so there's no way you will be able to convert them like this. You can convert the elements (even without the dynamic cast) but the lists ... not happening.

          Kind regards.

          Read and abide by the Qt Code of Conduct

          A 1 Reply Last reply
          1
          • kshegunovK kshegunov

            @Amott
            Hi!
            This will not work.QList<QWidget *> and QList<ElementArbo*> are two completely different (and unrelated classes) so there's no way you will be able to convert them like this. You can convert the elements (even without the dynamic cast) but the lists ... not happening.

            Kind regards.

            A Offline
            A Offline
            Amott
            wrote on last edited by
            #5

            @kshegunov
            ok thanks, I'll create a list of QWidgets and convert my element one by one
            thanks for your explainations !

            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