Results 1 to 2 of 2

Thread: Qt Creator - error: call of overloaded 'QMatrix4x4(const qreal*&)' is ambiguous

  1. #1

    Default Qt Creator - error: call of overloaded 'QMatrix4x4(const qreal*&)' is ambiguous

    I have a project in Qt Creator in Windows,When compiled I got this Error, I Googled a few, But I couldn't find the solution :

    \application\src\helpers.cpp:99: error: call of overloaded 'QMatrix4x4(const qreal*&)' is ambiguous
    QMatrix4x4 matrix(a);
    ^

    the line that has error:

    QMatrix4x4 matrix(a);so what should I do?

    helpers.cpp corresponded to the error:

    #include <iostream>
    #include <stdio.h>
    #include <string.h>
    #include <math.h>
    #include "helpers.h"
    #include <QMatrix4x4>
    #include <QtGui>

    Helpers :: Helpers()
    {
    }

    Helpers :: ~Helpers()
    {
    }

    //====================================================================
    // Normalize
    //====================================================================

    void Helpers::normalize(qreal *a)
    {
    double b;

    b = vlen(a);
    a[0] /= b;
    a[1] /= b;
    a[2] /= b;
    }

    //====================================================================
    // Length
    //====================================================================

    qreal Helpers::vlen(qreal *a)
    {
    return sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]);
    }

    //====================================================================
    // Cross product
    //====================================================================

    void Helpers::crossProduct(qreal *a, qreal *b, qreal *c)
    {
    c[0] = a[1]*b[2] - a[2]*b[1];
    c[1] = a[2]*b[0] - a[0]*b[2];
    c[2] = a[0]*b[1] - a[1]*b[0];
    }

    //====================================================================
    // Invert 4x4 matrix (for visualiztion only)
    //====================================================================
    //commented by John
    // pre start cooment
    void Helpers::invertMatrix(const qreal *a, qreal *inva)
    {

    QMatrix4x4 matrix(a);

    bool ok(true);

    QMatrix4x4 inverse(matrix.transposed().inverted(&ok));

    if(!ok) fprintf(stderr, "Error: Singular 4x4 matrix\n");

    for(int i = 0; i < 16; ++i)
    inva[i] = double(inverse.data()[i]);
    }
    //*/ pre end comment

    This is all errors that I see,after lots of debugging... I think the problem maybe about command syntax format or libraries definition and usage or something else...
    Last edited by hasanbaghal; 15th December 2017 at 07:59.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt Creator - error: call of overloaded 'QMatrix4x4(const qreal*&)' is ambiguous

    There is no QMatrix4x4 constructor that takes a pointer to a QMatrix4x4 as an argument. There -is- a constructor that takes a pointer to an array of float. There is no way for C++ to automatically convert a pointer to a QMatrix4x4 to a pointer to an array of float, so that is why you get a compilation error.

    If you don't understand what I am hinting at, here's another hint: Look carefully at your list of arguments to "invertMatrix()" and then look at the QMatrix4x4 docs and the list of allowed arguments to its constructors, and compare that with how you are trying to construct your temporary matrix.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 4
    Last Post: 25th September 2010, 12:58
  2. Replies: 2
    Last Post: 7th July 2009, 17:44
  3. Replies: 1
    Last Post: 10th February 2009, 09:42
  4. virtual overloaded functions and base class function call...
    By nouknouk in forum General Programming
    Replies: 7
    Last Post: 11th March 2006, 21:26
  5. ambiguous call to overloaded function
    By :db:sStrong in forum Qt Programming
    Replies: 18
    Last Post: 10th February 2006, 09:36

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.