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] Unresolved external symbol using QTableWidget
Forum Updated to NodeBB v4.3 + New Features

[solved] Unresolved external symbol using QTableWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 3 Posters 3.9k Views 2 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.
  • SGaistS SGaist

    unsigned __int64 ? Looks suspicious, setRowCount uses an int

    G Offline
    G Offline
    goishin
    wrote on last edited by
    #7

    @SGaist That's what I thought too. I've tried casting to a size_t, which is what the header for setRowCount uses. But that didn't affect the error message. I'm building using the MSVC 2013 64-bit toolkit. There were four options, 64 vs. 32 bit, and VC 2012 / VC 2013. Out of those options I prefer the one I chose, but in the interest of troubleshooting, I also tried some of the other options. But I was unable to use any of the other options as attempting to compile using the other options throws an error stating: "Qt creator needs a compiler set up to build." This tells me that I didn't accidentally switch to a different toolkit sometime in the middle of development and that's why I'm now getting this error. If I did switch to another toolkit, then I'd have had to set one up.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #8

      What header ? setRowCount uses an int

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply
      0
      • SGaistS SGaist

        What header ? setRowCount uses an int

        G Offline
        G Offline
        goishin
        wrote on last edited by
        #9

        @SGaist Well THAT's weird. I had ctrl+clicked on setRowCount before, and the header file said it used a size_t in the qtablewidget.h file. But when I ctrl+click on setRowCount in the new project, the qtablewidget.h file has the parameter as an int. What gives?

        Regardless of that, your last comment had me thinking it might be type related. So I also tried declaring an __int32, and passed that variable in. That didn't work. I also tried a number of other types, such as regular int, size_t again, and unsigned __int32. Nothing changed.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #10

          Can you share your code ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          G 1 Reply Last reply
          0
          • SGaistS SGaist

            Can you share your code ?

            G Offline
            G Offline
            goishin
            wrote on last edited by
            #11

            @SGaist I already posted the code for the brand new project. But here's the mainwindow.cpp file from the old pre-existing project:

            #include "mainwindow.h"
            #include "ui_mainwindow.h"
            #include <qtreewidget.h>
            #include <QtDebug>
            
            MainWindow::MainWindow(QWidget *parent) :
                QMainWindow(parent),
                ui(new Ui::MainWindow),
                CurrentlySelectedAccount( nullptr )
            {
                financials::TheCalculator* calc = new financials::TheCalculator();
            
                QString filename( "C:\\source\\QT_Projects\\FinancialExplorer\\InputFinancials.ini" );
                calc->ParseInputFile( filename );
                this->CurrentSimulation = calc;
            
                ui->setupUi(this);
                ui->Accounts->setAnimated( true );
            
                auto AccountsMap = calc->GetAccounts();
                auto iter = AccountsMap.begin();
                QTreeWidget* accounts = ui->Accounts;
                bool isFirst = true;
                auto selectedIter = AccountsMap.begin();
                while( iter != AccountsMap.end() )
                {
                    QTreeWidgetItem* item = new QTreeWidgetItem( accounts, 2 ); // 2 means "Don't show expander if no children"
            
                    item->setText( 0, calc->GetName() );
            
                    // add properties
                    QTreeWidgetItem* StartDateItem = new QTreeWidgetItem( item, 0 );
                    QString startDateLabel( "Start Date:" );
                    startDateLabel.append( calc->GetStartDate().toString());
                    StartDateItem->setText( 0, startDateLabel );
            
                    QTreeWidgetItem* EndDateItem = new QTreeWidgetItem( item, 0 );
                    QString EndDateLabel( "End Date:" );
                    EndDateLabel.append( calc->GetEndDate().toString());
                    EndDateItem->setText( 0, EndDateLabel );
            
                    QTreeWidgetItem* CurrentDateItem = new QTreeWidgetItem( item, 0 );
                    QString CurrentDateLabel( "Current Date:" );
                    CurrentDateLabel.append( calc->GetCurrentDate().toString());
                    CurrentDateItem->setText( 0, CurrentDateLabel );
            
                    // add accounts
                    QTreeWidgetItem* accountsItem = new QTreeWidgetItem( item, 2 );
                    accountsItem->setText( 0, "Accounts" );
                    for( auto& account : calc->GetAccounts() )
                    {
                        QTreeWidgetItem* accItem = new QTreeWidgetItem( accountsItem, 2 );
                        accItem->setText( 0, account.second.GetName() );
                        accItem->setText( 1, "I'm an account description" );
                    }
            
                    // add events
                    QTreeWidgetItem* eventsItem = new QTreeWidgetItem( item, 2 );
                    eventsItem->setText( 0, "Events" );
                    for( auto& event : calc->GetEvents() )
                    {
                        QTreeWidgetItem* eventItem = new QTreeWidgetItem( eventsItem, 2 );
                        eventItem->setText( 0, event.GetName() );
                        eventItem->setText( 1, "I'm an event description" );
                    }
                    item->setText(1, "I'm a description");
                    if( isFirst )
                    {
                        item->setSelected( true );
                        selectedIter = iter;
                        isFirst = false;
                    }
                    ++iter;
                }
            
                connect(ui->Accounts,&QTreeWidget::itemClicked,this,&MainWindow::on_MyTree_itemClicked);
            
                RefreshTable();
            }
            
            void MainWindow::RefreshTable()
            {
                financials::TheCalculator* calc = CurrentSimulation;
                if( calc != nullptr )
                {
                    size_t lengthOfSimulation = calc->GetLengthOfSimulation();
                    ui->Spreadsheet->setRowCount( lengthOfSimulation );
                    size_t accountsSize = calc->GetAccounts().size();
                    ui->Spreadsheet->setColumnCount( accountsSize );
            
                    int rowIndex = 0;
                    while( calc->IsRunning() )
                    {
                        QString value;
                        auto accounts = calc->GetAccounts();
                        auto accountsIter = accounts.begin();
                        int colIndex = 0;
                        while( accountsIter != accounts.end() )
                        {
                            value = QString::number( (*accountsIter).second.GetCurrentBalance() );
                            ui->Spreadsheet->setItem(rowIndex, colIndex++, new QTableWidgetItem( value ));
                            ++accountsIter;
                        }
                        calc->IncrementMonth();
                        ++rowIndex;
                    }
                }
            }
            
            void MainWindow::on_MyTree_itemClicked ( QTreeWidgetItem * item, int column )
            {
                qDebug() << "on_MyTree_itemClicked"
                    << item->text(column);
                //to do somthing
            
                QString text = item->text(column);
                if( CurrentSimulation != nullptr )
                {
                    auto iter = CurrentSimulation->GetAccounts().find( text );
                    if( iter != CurrentSimulation->GetAccounts().end() )
                    {
                        if( CurrentAccountName != text )
                        {
                            CurrentAccountName = text;
                            CurrentlySelectedAccount = &((*iter).second);
                            RefreshTable();
                        }
                    }
                }
            }
            
            MainWindow::~MainWindow()
            {
                delete ui;
            }
            
            
            

            And here's the .pro file from the old project:

            #-------------------------------------------------
            #
            # Project created by QtCreator 2015-08-26T18:06:52
            #
            #-------------------------------------------------
            
            QT       += core gui widgets
            
            greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
            
            TARGET = FinancialExplorer
            TEMPLATE = app
            
            
            SOURCES += main.cpp\
                    mainwindow.cpp \
                accounts.cpp \
                thecalculator.cpp \
                financials.cpp \
                events.cpp
            
            HEADERS  += mainwindow.h \
                accounts.h \
                financials.h \
                thecalculator.h \
                events.h \
                qstringhashfunction.h
            
            FORMS    += mainwindow.ui
            
            DISTFILES += \
                InputFinancials.ini
            
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #12

              Do you also experience the same problem if you create a new project and use QTableWidget in it ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              G 1 Reply Last reply
              0
              • SGaistS SGaist

                Do you also experience the same problem if you create a new project and use QTableWidget in it ?

                G Offline
                G Offline
                goishin
                wrote on last edited by goishin
                #13

                @SGaist Yes. It appears that I do. I just created a brand new project with nothing in it but the QTableWidget. When I added lines to call setRowCount and setColumnCount I got the same error.

                Does this mean I have something misconfigured?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #14

                  I wonder if you don't have your Qt headers corrupted

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  G 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    I wonder if you don't have your Qt headers corrupted

                    G Offline
                    G Offline
                    goishin
                    wrote on last edited by
                    #15

                    @SGaist Yup, looks like that was it. I uninstalled Qt and reinstalled it and that fixed everything.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #16

                      Great :)

                      By the way, since the last forum update, you can use the Topic Tool button to mark your thread as solved :)

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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