Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]Help - Unclear errors - Don't know where to post.
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Help - Unclear errors - Don't know where to post.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    glowdemon1
    wrote on last edited by
    #1

    Hi, first off all I'm sorry if I posted this in the incorrect section, the forums are kinda unclear for me. Also, I'm new to QT since a few days, I know basic C++ and I tried to make a payday calculator, I'm stuck with some code. The errors seem unclear for me, thanks in advance and again I'm sorry if I posted this incorrectly. Also, the script itself isn't made to work yet like it should, I just needed to do some testing first.

    mainwindow.cpp
    @#include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent):QMainWindow(parent),ui(new Ui::MainWindow){

    ui->setupUi(this);
    ui->mainTable->setColumnWidth(0,50);
    ui->mainTable->setColumnWidth(1,151);
    
    ui->mainTable->verticalHeader()->setVisible(false);
    

    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::addTaxes(int time, int taxes, int net){
    int x = 0;
    int rate = 2;

    ui->mainTable->setRowCount(time);
    
    for(int i=0; i<time; i++){
        QTableWidgetItem* item = new QTableWidgetItem();
        QTableWidgetItem* itemDeux = new QTableWidgetItem();
    
        x = ((net/100)*rate)-taxes;
        net = net + x;
        item->setText(QString::number(i));
        ui->mainTable->setItem(i,0,item);
    
        itemDeux->setText("$" + QString::number(net));
        ui->mainTable->setItem(i,1,itemDeux);
    
        ui->mainTable->setRowHeight(i,10);
    }
    

    }

    void MainWindow::on_calculateButton_clicked(){
    //int time = ui->timeEdit->text().toInt();
    int taxes = 0;
    int net = 0;
    int time = 0;

    addTaxes(time,taxes,net);
    

    }
    @

    errors:
    @C:\Users\Robbe\Desktop\workspace\PaydayCalculator\mainwindow.cpp:19: error: prototype for 'void MainWindow::addTaxes(int, int, int)' does not match any in class 'MainWindow'
    void MainWindow::addTaxes(int time, int taxes, int net){
    ^@

    @C:\Users\Robbe\Desktop\workspace\PaydayCalculator\mainwindow.h:23: error: candidate is: void MainWindow::addTaxes()
    void addTaxes();
    ^@
    @C:\Users\Robbe\Desktop\workspace\PaydayCalculator\mainwindow.cpp:47: error: no matching function for call to 'MainWindow::addTaxes(int&, int&, int&)'
    addTaxes(time,taxes,net);
    ^@

    header
    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>

    namespace Ui {
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    private slots:
    void on_calculateButton_clicked();

    private:
    Ui::MainWindow *ui;
    void addTaxes();
    };

    #endif // MAINWINDOW_H
    @

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi, and welcome to the Qt Dev Net!

      What you say in your .h file needs to match what you say in your .cpp file:

      [quote]
      @
      // mainwindow.h
      void addTaxes();
      @

      @
      // mainwindow.cpp
      void MainWindow::addTaxes(int time, int taxes, int net){
      ...
      @
      [/quote]Your .h file says addTaxes takes 0 parameters, but your .cpp file says it takes 3 int parameters. Which is is correct?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • G Offline
        G Offline
        glowdemon1
        wrote on last edited by
        #3

        [quote author="JKSH" date="1396831350"]Hi, and welcome to the Qt Dev Net!

        What you say in your .h file needs to match what you say in your .cpp file:

        [quote]
        @
        // mainwindow.h
        void addTaxes();
        @

        @
        // mainwindow.cpp
        void MainWindow::addTaxes(int time, int taxes, int net){
        ...
        @
        [/quote]Your .h file says addTaxes takes 0 parameters, but your .cpp file says it takes 3 int parameters. Which is is correct?[/quote]

        Thanks a lot, I knew about this but I forgot to add the parameters to the header file as you said.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved