How to include .txt on Qt
- 
mrjj: SORRY i edited your post!. browser lag. cannot undo 
 Im very sorry.- Yes i have already do that u explained to me before ^^
 Oh. sorry. Well now we know its working :)
 seems good. Note its single ":/" not "://"
 and i dont understand the "Give pix to painter" When you construct the painter you give it the widget normally 
 QPainter painter(this); <<< "this" being the widget pointer
 but when we paint on image then we give pixmap instead of "this"
 QPainter painter(&pix); // pix is pixmap and not widget
 So basically we tell painter to draw on this picmap and not on a widget.
- Yes i have already do that u explained to me before ^^
- 
mrjj: SORRY i edited your post!. browser lag. cannot undo 
 Im very sorry.- Yes i have already do that u explained to me before ^^
 Oh. sorry. Well now we know its working :)
 seems good. Note its single ":/" not "://"
 and i dont understand the "Give pix to painter" When you construct the painter you give it the widget normally 
 QPainter painter(this); <<< "this" being the widget pointer
 but when we paint on image then we give pixmap instead of "this"
 QPainter painter(&pix); // pix is pixmap and not widget
 So basically we tell painter to draw on this picmap and not on a widget.@Payx 
 So you last issue is the painting of the little image.Since we are not allowed to paint inside Remplissage, you have 2 options. Do this in paintEvent. ( meaning call Remplissage ) 
 or
 let Remplissage paint on a new pixmap and then later paint this new pix in
 the real paintEvent function.
- Yes i have already do that u explained to me before ^^
- 
@Payx said in How to include .txt on Qt: What is the simpliest method ? ahah I think to paint on image as you can then later just 
 show in QLabel and might not even need to make a PaintEvent.
 This new image should be the size of the red rect one where u scan for colors.
 so you will draw the mini images on this new picmap and then its the final pixmap i assume.
- 
so in this loop for(int x = topLeft.x(); x < maxX; ++x) { for(int y = topLeft.y(); y < maxY; ++y) {i can include QLabel *label = new QLabel(this); foreach( QRgb key, Costs.keys() ) { QColor BaseColor( key ); if (Costs.contains( colour.rgb() ) || IsCloseColor(BaseColor, colour) ) { CostInfo& ci = Costs[colour.rgb()]; // int Cost = ci.Cost; QPixmap pix( ci.ImageName ); QPixmap scaledPix = pix.scaled( 8, 8, Qt::KeepAspectRatio, Qt::SmoothTransformation ); ui->label->setPixmap(pix);? 
- 
so in this loop for(int x = topLeft.x(); x < maxX; ++x) { for(int y = topLeft.y(); y < maxY; ++y) {i can include QLabel *label = new QLabel(this); foreach( QRgb key, Costs.keys() ) { QColor BaseColor( key ); if (Costs.contains( colour.rgb() ) || IsCloseColor(BaseColor, colour) ) { CostInfo& ci = Costs[colour.rgb()]; // int Cost = ci.Cost; QPixmap pix( ci.ImageName ); QPixmap scaledPix = pix.scaled( 8, 8, Qt::KeepAspectRatio, Qt::SmoothTransformation ); ui->label->setPixmap(pix);? 
- 
Because it will not return only one picture, if my picture is 540540 and my rectangle is 88 i cannot just add a label to display 70 picture. at the end it will have http://www.hostingpics.net/viewer.php?id=354728program.png by replacing all the rectangle by a picture, it depends the color of the rectangle 
- 
@ambershark Lol I prefer learn instead of just don't understand what i'm doing, i know i'm very bad to programmation by now but maybe in few years i'il be like mrjj haha ! for the QPoint, i use it here : void MainWindow::on_push2_clicked() { for (int i=0;i<pixi.width();i+=z){ for (int j=0;j<pixi.height();j+=z){ k=k+0.06; Remplissage(pixi,QPoint(i,j),QSize(z,z),Couleurdominante(pixi,QPoint(i,j),QSize(z,z))); } }but i use the QPixmap scaledPix ..... 
 in my functionvoid Remplissage(QImage& image, const QPoint& topLeft, const QSize& rectangle, const QColor& colour) {so it tell that j and i was not declared in this scope so i declared i and j in my .h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QPixmap> #include <QPoint> #include <QSize> #include <iostream> #include <QMapIterator> #include <QMap> namespace Ui { class MainWindow; } struct CostInfo { QString ImageName; int Cost; }; int j; int i; 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); private: Ui::MainWindow* ui; QImage pixi; QPixmap pixa; float k; int a; int z = 1; int b; }; #endif // MAINWINDOW_HHit will work? // it tell that painter was not declared too, so i search to the QPainter class, it's "void QPainter::drawPixmap(const QPoint & point, const QPixmap & pixmap)" that i should use ? @Payx said in How to include .txt on Qt: @ambershark Lol I prefer learn instead of just don't understand what i'm doing, i know i'm very bad to programmation by now but maybe in few years i'il be like mrjj haha ! Haha it's good that you are learning instead of asking for it done like a lot of people on these forums. And hey we all started out bad, don't worry you'll be good in no time if you stick with it. ;) I was just quite impressed with the number of posts in this topic. 
- 
@Payx said in How to include .txt on Qt: @ambershark Lol I prefer learn instead of just don't understand what i'm doing, i know i'm very bad to programmation by now but maybe in few years i'il be like mrjj haha ! Haha it's good that you are learning instead of asking for it done like a lot of people on these forums. And hey we all started out bad, don't worry you'll be good in no time if you stick with it. ;) I was just quite impressed with the number of posts in this topic. @ambershark No problem ^^! 
- 
I tried something without you (sorry ahah) QLabel abc; abc.setPixmap(scaledPix); abc.show();it compiles but there is a error : QPixmap::scaled: Pixmap is a null pixmap @Payx said in How to include .txt on Qt: scaledPix Sounds like scaledPix is not initialize as it should , which often 
 comes from not being able to load a file.Make sure the image you are scaling, is indeed valid. (loaded) 
- 
Before posting, i've tried to just QPixmap pix(":/img/ballebleue.png") ui->setPixmap .....and it works u said "scaledPix is not initialize as it should ?" EDIT : Happy New Year ! Yes That would make the pix valid. To get the error " Pixmap is a null pixmap" for scaledPix means that 
 it was not valid. It was empty. so if it came from a scale function, it means
 that the image u scaled to get scaledPix was empty.Happy new Year :) 
- 
QLabel abc; // int Cost = ci.Cost; QPixmap pix( ci.ImageName ); QPixmap scaledPix = pix.scaled( 8, 8, Qt::KeepAspectRatio, Qt::SmoothTransformation ); abc.setPixmap(scaledPix); abc.show();i have this : so the error come from "QPixmap pix" who is empty so the line "QPixmap pix( ci.ImageName );" dont create a pixmap from my QMap ? 
- 
- QPixmap pix( ci.ImageName );" dont create a pixmap from my QMap ?
 That would be my guess yes. You can check pix with isNull() 
- 
So i add the if : if (pix.isNull()){ QPixmap pix(":/img/ballebleue.png"); };Same error as before "QPixmap::scaled: Pixmap is a null pixmap" @Payx said in How to include .txt on Qt: if (pix.isNull()){ 
 QPixmap pix(":/img/ballebleue.png");
 };Well that would not really change anything as you create a new local pix and its not related to the "pix" outside 
 You should find out if its invalid and then why it isif (pix.isNull()){ 
 qDebug() << "yep its no good";
 return;
 };
