Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8853277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:36:45+00:00 2026-06-14T13:36:45+00:00

In the book C++ GUI Programming with Qt 4 there’s a FindDialog Widget example

  • 0

In the book “C++ GUI Programming with Qt 4” there’s a FindDialog Widget example show step by step in Part 1, Chapter 2, now I’m trying to build this example using the Makefile generated by qmake but it complains saying:

g++ -Wl,-O1 -o Hello hello.o    -L/usr/lib/i386-linux-gnu -lQtGui -lQtCore -lpthread 
hello.o: In function `main':
hello.cpp:(.text.startup+0x47): undefined reference to `FindDialog::FindDialog(QWidget*)'
collect2: ld returned 1 exit status
make: *** [Hello] Error 1

Using the shell command prompt (on Linux Mint)
I’ve created a directory Hello
I’ve created a project file (with qmake) Hello.pro
This is the ls command output in /Hello:

FindDialog.cpp  FindDialog.h  hello.cpp  hello.o  Hello.pro  Makefile

I’ve been trying to figure out the problem for 2 hours now, I would be very grateful of any help thank you.

This is the file containing main :

#include "FindDialog.h"

int main(int argc, char *argv[])
 {
 QApplication app(argc, argv);
 FindDialog *dialog = new FindDialog();
 dialog->show();
 return app.exec();
 }

Header file: FindDialog.h

#ifndef FIND_DIALOG_H
#define FIND_DIALOG_H
#include <QDialog>
class QCheckBox;
class QLabel;
class QLineEdit;
class QPushButton;

class FindDialog : public QDialog
{
  Q_OBJECT

  public:
   FindDialog(QWidget* parent = 0);
   ~FindDialog();
   signals:
   void findNext(const QString &str, Qt::CaseSensitivity cs);
   void findPrevious(const QString &str, Qt::CaseSensitivity cs);
  private slots:
   void findClicked();
   void enableFindFunction(const QString &text);
  private:
   QLabel *label;
   QLineEdit *lineEdit;
   QCheckBox *caseCheckBox;
   QCheckBox *backwardCheckBox;
   QPushButton *findButton;
   QPushButton *closeButton;
};

#endif

Implementation File: FindDialog.cpp

#include <QtGui>
#include "FindDialog.h"

FindDialog::FindDialog(QWidget *parent = 0):QDialog(parent)
{
   //Creating components
   label = new QLabel(tr("Find &what : "));
   lineEdit = new QLineEdit;
   label->setBuddy(lineEdit);

   caseCheckBox = new QCheckBox(tr("Match &case"));
   backwardCheckBox = new QCheckBox(tr("Search &backward"));
   findButton = new QPushButton(tr("&Find"));
   findButton->setDefault(true);
   findButton->setEnabled(false);
   closeButton = new QPushButton(tr("close"));
   //adding event handling
   connect(lineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(enableFindButton(const QString &)));
   connect(findButton, SIGNAL(clicked()), this, SLOT(findClicked()));
   connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
   //setting layout
   QHBoxLayout *topLeftLayout = new QHBoxLayout;
   topLeftLayout->addWidget(label);
   topLeftLayout->addWidget(lineEdit);

   QVBoxLayout *leftLayout = new QVBoxLayout;
   leftLayout->addLayout(topLeftLayout);
   leftLayout->addWidget(caseCheckBox);
   leftLayout->addWidget(backwardCheckBox);

   QVBoxLayout *rightLayout = new QVBoxLayout;
   rightLayout->addWidget(findButton);
   rightLayout->addWidget(closeButton);
   rightLayout->addStretch();

   QHBoxLayout *mainLayout = new QHBoxLayout;
   mainLayout->addLayout(leftLayout);
   mainLayout->addLayout(rightLayout);
   setLayout(mainLayout);
   //window title
   setWindowTitle(tr("Find"));
   setFixedHeight(sizeHint().height());
  }
 FindDialog::~FindDialog(){
 }
 void FindDialog::findClicked()
 {
   QString text = lineEdit->text();
   Qt::CaseSensitivity cs = caseCheckBox->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive;
   if (backwardCheckBox->isChecked()) {
      emit findPrevious(text, cs);
   }
   else {
      emit findNext(text, cs);
   }
  }
  void FindDialog::enableFindButton(const QString &text)
  {
    findButton->setEnabled(!text.isEmpty());
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:36:46+00:00Added an answer on June 14, 2026 at 1:36 pm

    Lol4t0’s answer solved your problem.
    You have just to rerun qmake -project.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Guys from book C++ GUI programming with qt I'm reading a chapter on how
I'm reading the book 'Beginning F#', There's a short list for example code, to
So new to Qt. Read the wiki and C++ Gui programming book and they
So, I'm reading this book: C++ GUI Programming with Qt 4, Second Edition by
I'm looking an e-book or some example/samples/tutorials for reach GUI implementation with 3d animation
I've recently began working through a C++ Gui Programming with Qt 4 book. However,
I have a problem in compiling a qt example from c++ GUI programming with
this is basic example I got for a GUI from a book called Java
Summerfield's Rapid GUI Programming with Python and Qt. I love the book in general.
in the book that i'm reading, every example of GUI with multithreading has something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.