Not Fast Enough
13th April 2010, 13:16
Hello all,
I'm in the process of learning c++ and read Thinking in c++, its lovely book. I ordered a book called C++ GUI Programming with Qt 4 (2nd Edition), but it wont arrive until next week. I use a mac and i wanted to develop a small program that would work on windows and mac and my professor recommended QT Framework for me. any way, please forgive me for my extremely newbie question: I have Created an interface in QT to load an image and display it in a Qlabel, and i was able to load the image in a label that pops up and not in the Qlabel that i already created in the designer view which already hold the same name:
void MainWindow::on_btnLoadImage_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open File"), QDir::currentPath());
if (!fileName.isEmpty()) {
QImage image(fileName);
if (image.isNull()) {
QMessageBox::information(this, tr("Image Viewer"),
tr("Cannot load %1.").arg(fileName));
return;
}
imageLabel = new QLabel;
imageLabel->setPixmap(QPixmap::fromImage(image));
imageLabel->show();
}
}
I didn't get the idea of slots and signals and still understanding how to create a class and call its member functions, every book talks about apples, oranges, cars, wheels, engines, shapes, circles, squares and stuff like that and its still not making sense to me.
please advice me on how to update different Qlabels -that i already put in the designer view- with images and text.
thanks for the help in advance
I'm in the process of learning c++ and read Thinking in c++, its lovely book. I ordered a book called C++ GUI Programming with Qt 4 (2nd Edition), but it wont arrive until next week. I use a mac and i wanted to develop a small program that would work on windows and mac and my professor recommended QT Framework for me. any way, please forgive me for my extremely newbie question: I have Created an interface in QT to load an image and display it in a Qlabel, and i was able to load the image in a label that pops up and not in the Qlabel that i already created in the designer view which already hold the same name:
void MainWindow::on_btnLoadImage_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open File"), QDir::currentPath());
if (!fileName.isEmpty()) {
QImage image(fileName);
if (image.isNull()) {
QMessageBox::information(this, tr("Image Viewer"),
tr("Cannot load %1.").arg(fileName));
return;
}
imageLabel = new QLabel;
imageLabel->setPixmap(QPixmap::fromImage(image));
imageLabel->show();
}
}
I didn't get the idea of slots and signals and still understanding how to create a class and call its member functions, every book talks about apples, oranges, cars, wheels, engines, shapes, circles, squares and stuff like that and its still not making sense to me.
please advice me on how to update different Qlabels -that i already put in the designer view- with images and text.
thanks for the help in advance