473,378 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

QT GUI Toolkit: beginer

So I am learning QT. But I can't seem to ge past 2 errors that seem to make no sense to me, "error "ui" was not declared in this scope". what get me is that I have the same thing on the next line, but no error...

simplecalc.cpp
Expand|Select|Wrap|Line Numbers
  1. #include <QtGui> 
  2.  #include <QMessageBox>  
  3. #include "simplecalc.h"   
  4. //using namespace UI; 
  5. simplecalc::simplecalc(QWidget *parent)     : QDialog(parent)
  6.  {
  7.        ui.setupUi(this);     //error
  8.        connect( ui.calc, SIGNAL( clicked() ), this, SLOT( doSomething() ) );
  9.        connect( ui.pushButton_quit, SIGNAL( clicked() ), this, SLOT( quit() ) );
  10.        connect( ui.pushButton_about, SIGNAL( clicked() ), this, SLOT( about() ) );  
  11. }
  12.  
  13.    void simplecalc::doSomething()
  14. {     
  15.             double value1, value2;
  16.      char func;
  17.  
  18.       value1 = ui.num1->value();        //error
  19.     //value1 = ui.num1->value();
  20.      value2 = ui.num2->value();
  21.      func = ui.sign->currentText();
  22.  
  23.       if(func=='x')
  24.          ui.ans->settext() = value1 * value2;
  25.      else if(func=='÷')
  26.          ui.ans->settext(value1 / value2);
  27.      else if(func=='-')
  28.          ui.ans->settext(value1 - value2);
  29.      else if(func=='+') 
  30.         ui.ans->settext(value1 + value2);
  31.      //ans->settext() = value1 func value2; }
  32.  
  33. void simplecalc::about()  
  34. {
  35.      QMessageBox::information(this, tr("About\n\n"),
  36.                     tr("This is a simple calculator program created by Josh Dye.\n")); }
simplecalc.h
Expand|Select|Wrap|Line Numbers
  1. #ifndef SIMPLECALC_H
  2. #define SIMPLECALC_H
  3.  
  4. #include "ui_SimpleCalc.h"
  5.  
  6.  
  7. class simplecalc : public QDialog
  8. {
  9.     Q_OBJECT
  10.  
  11. public:
  12.     simplecalc(QWidget *parent = 0);
  13.  
  14. public slots:
  15.     void doSomething();
  16.     void about();
  17.  
  18. };
  19. #endif
Apr 25 '08 #1
2 1577
Laharl
849 Expert 512MB
There's nothing the second time because undefined references are only flagged once/function. The issue here is that you never say what 'ui' is. If it's supposed to be the namespace UI, you don't need it there, as long as you uncomment the using directive. If it's some kind of object, you need to create it.
Apr 26 '08 #2
I got help on another forum

:closed:
Apr 26 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Greg Scharlemann | last post by:
I am attempting to upload a picture to a webserver and create a thumbnail from the picture uploaded. The problem comes in when I attempt to create an Image object from the File object (which is...
6
by: Martin Bless | last post by:
The good news: Along with Python-2.4 comes really good news to Windows users. Yes, you now CAN build extension modules yourself using the SAME C++ compiler and linker Python is built with...
0
by: Chive Software | last post by:
Chive Software are pleased to announce a new version of its Apoc PDF Toolkit, part a of its Apoc suite of products. Apoc PDF Toolkit is a high quality software component that developers can add...
2
by: Ney André de Mello Zunino | last post by:
Hello. I gladly learned yesterday that Microsoft was making the Visual C++ Toolkit 2003 available for free. Today, I downloaded and installed it and went on to try building some simple...
10
by: miffy900 | last post by:
Will there be a Visual C++ Toolkit 2005? I really appreciated that there was the Visual C++ 2003 Optimising Compiler distributed for free in the 2003 Toolkit. Will Microsoft continue with this...
6
by: Rental | last post by:
I'm having the sam problem as described below with the Localization toolkit. Does anyone know if there is a solution to this problem. --->When attempting to generate resource dlls with...
24
by: invitro81 | last post by:
Hello I've recently learnt python and I do love it! I congratulate all those geeks who produce this nice language; well, because I could be called a nearby newbee I've decided to improve my...
1
by: itsjyotika | last post by:
Hello Everyone, I need to read data from a CVS file(i created it from micosoft excel) and then need to match it with the one of the date from the command line.If the date is there then it should say...
5
by: hn.ft.pris | last post by:
Hi: I'm a beginer of STL, and I'm wondering why none of below works: ######################################################################## .......... string str("string"); if ( str == "s" )...
1
by: hamed steph | last post by:
i'm a beginer in programing and i need very much your help .i need explanation about while statement (loop initialization and structure of while ) also qualifier (long,short,unsigned ,signed,) type...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.