How to include .txt on Qt
Unsolved
General and Desktop
-
Maybe you use it above where you define it or maybe u didnt show it how CostInfo is defined.
-
I defined my QMap here :
QMap<QRgb, CostInfo > Costs = { { QColor(255 , 0 , 0 ).rgb(), { "://fraise.png", 10 }}, { QColor(0 , 255 , 0 ).rgb(), { "://balleverte.png", 20 }}, { QColor(0 , 0 , 255 ).rgb(), { "://ballebleue.png", 20 }}, { QColor(255 , 255 , 255 ).rgb(), { "://balleblanche.png", 20 }}, { QColor(255 , 128 , 0 ).rgb(), { "://ballepeche.png", 20 }}, { QColor(0 , 0 , 0 ).rgb(), { "://noir.png", 20 }}, { QColor(102 , 51 , 0 ).rgb(), { "://marron.png", 20 }}, { QColor(255 , 102 , 78 ).rgb(), { "://rose.png", 20 }}, { QColor(0 , 204 , 204 ).rgb(), { "://turquoise.png", 20 }}, { QColor(255 , 178 , 102 ).rgb(), { "://beige.png", 20 }}, { QColor(76 , 0 , 153 ).rgb(), { "://violet.png", 20 }}, { QColor(100 , 100 , 100 ).rgb(), { "://gris.png", 20 }}, };
And this is a function call no ?
QMapIterator<QRgb, CostInfo>i;
-
Hi
And where is the definition for CostInfo ? -
@Flotisable Thank you,
so i have to define CostInfo as an int ?
-
i got
QMap<QRgb, CostInfo > Costs = { { QColor(255 , 0 , 0 ).rgb(), { "://fraise.png", 10 }}, { QColor(0 , 255 , 0 ).rgb(), { "://balleverte.png", 20 }}, { QColor(0 , 0 , 255 ).rgb(), { "://ballebleue.png", 20 }}, { QColor(255 , 255 , 255 ).rgb(), { "://balleblanche.png", 20 }}, { QColor(255 , 128 , 0 ).rgb(), { "://ballepeche.png", 20 }}, { QColor(0 , 0 , 0 ).rgb(), { "://noir.png", 20 }}, { QColor(102 , 51 , 0 ).rgb(), { "://marron.png", 20 }}, { QColor(255 , 102 , 78 ).rgb(), { "://rose.png", 20 }}, { QColor(0 , 204 , 204 ).rgb(), { "://turquoise.png", 20 }}, { QColor(255 , 178 , 102 ).rgb(), { "://beige.png", 20 }}, { QColor(76 , 0 , 153 ).rgb(), { "://violet.png", 20 }}, { QColor(100 , 100 , 100 ).rgb(), { "://gris.png", 20 }}, };
in my .cpp
and struct in my .h,
do i paste "QMap<QRgb, CostInfo > Costs;" in my .cpp like my function or in my .h (sorry but i didnt understand ur question ^^)
-
i think i fixed it i had :
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QPixmap> #include <QPoint> #include <QSize> #include <iostream> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); struct CostInfo { QString ImageName; int cost; }; ~MainWindow(); private slots: void on_push_clicked(); void on_push2_clicked(); void on_verticalSlider_sliderMoved(int position); void on_verticalSlider_actionTriggered(int action); private: Ui::MainWindow *ui; QImage pixi; QPixmap pixa; float k; int a; int z=1; int b; }; #endif // MAINWINDOW_H
and now i remember that i have to paste in the .h but not in public or private so i have :
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QPixmap> #include <QPoint> #include <QSize> #include <iostream> namespace Ui { class MainWindow; } struct CostInfo { QString ImageName; int cost; }; class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_push_clicked(); void on_push2_clicked(); void on_verticalSlider_sliderMoved(int position); void on_verticalSlider_actionTriggered(int action); private: Ui::MainWindow *ui; QImage pixi; QPixmap pixa; float k; int a; int z=1; int b; }; #endif // MAINWINDOW_H
and what is this line :
QMapIterator<QRgb, CostInfo> i;
because it say "no matching function to call"
-
I wonder if you dont have c++11 compiler.
"no matching function to call"
Make sure you have included QMapIterator