Results 1 to 20 of 54

Thread: QTableWidget problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: QTableWidget problem

    Ok, then back to docs ... But I do not get this roles . I've looked them up in docs, the roles are used for editing, rendering data ... not for data type itself ...
    Qt 5.3 Opensource & Creator 3.1.2

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QTableWidget problem

    The point is that every row consists of two lines, the upper one will hold merchandize name (solo column) and the lower one will consists of following fields in order:

    * price/merchandize unit (eur formatted, including euro sign
    * number of merchandize unit (formatted with leading 0)
    * price/unit*number of merchandize units (eur formatted, including euro sign)
    * at the end there will be total field
    I see different pieces of data here, don't you?

  3. #3
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: QTableWidget problem

    Quote Originally Posted by wysota View Post
    I see different pieces of data here, don't you?
    So, quote fomr the docs:
    Each item in the model has a set of data elements associated with it, each with its own role. The roles are used by the view to indicate to the model which type of data it needs.
    So, for this each data from struct I need a whole familiy of this roles (numbers)?!
    Qt 5.3 Opensource & Creator 3.1.2

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QTableWidget problem

    For each data piece you need one role.

  5. #5
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Red face Re: QTableWidget problem

    Ok, I am slowly getting somewhere, but in the statement:
    Qt Code:
    1. m_pShoppingCartView->model()->setData(index, QVariant((m_pShoppingCartView->order()->orders().size()), 1));
    To copy to clipboard, switch view to plain text mode 

    I get following error:
    Qt Code:
    1. mingw32-make
    2. mingw32-make -f Makefile.Debug
    3. mingw32-make[1]: Entering directory `C:/Documents and Settings/markofr/workspace/Client'
    4. g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include" -I"c:\Qt\4.3.4\include\ActiveQt" -I"debug" -I"." -I"..\..\..\..\Qt\4.3.4\mkspecs\win32-g++" -o debug\CMainWindow.o CMainWindow.cpp
    5. g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include" -I"c:\Qt\4.3.4\include\ActiveQt" -I"debug" -I"." -I"..\..\..\..\Qt\4.3.4\mkspecs\win32-g++" -o debug\COperationWIndow.o COperationWIndow.cpp
    6. ../../../../Qt/4.3.4/include/QtCore/../../src/corelib/kernel/qvariant.h: In member function `void COperationWIndow::chooseMerchandize()':
    7. ../../../../Qt/4.3.4/include/QtCore/../../src/corelib/kernel/qvariant.h:415: error: `QVariant::QVariant(bool, int)' is private
    8. COperationWIndow.cpp:284: error: within this context
    9. mingw32-make[1]: *** [debug/COperationWIndow.o] Error 1
    10. mingw32-make[1]: Leaving directory `C:/Documents and Settings/markofr/workspace/Client'
    11. mingw32-make: *** [debug] Error 2
    To copy to clipboard, switch view to plain text mode 

    The very similiar line of code from example works fine. Why?!
    Qt 5.3 Opensource & Creator 3.1.2

  6. #6
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: QTableWidget problem

    Quote Originally Posted by MarkoSan View Post
    Ok, I am slowly getting somewhere, but in the statement:
    Qt Code:
    1. m_pShoppingCartView->model()->setData(index, QVariant((m_pShoppingCartView->order()->orders().size()), 1));
    To copy to clipboard, switch view to plain text mode 
    I get following error:
    Qt Code:
    1. mingw32-make
    2. mingw32-make -f Makefile.Debug
    3. mingw32-make[1]: Entering directory `C:/Documents and Settings/markofr/workspace/Client'
    4. g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include" -I"c:\Qt\4.3.4\include\ActiveQt" -I"debug" -I"." -I"..\..\..\..\Qt\4.3.4\mkspecs\win32-g++" -o debug\CMainWindow.o CMainWindow.cpp
    5. g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtCore" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtGui" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include\QtSql" -I"..\..\..\..\Qt\4.3.4\include" -I"c:\Qt\4.3.4\include\ActiveQt" -I"debug" -I"." -I"..\..\..\..\Qt\4.3.4\mkspecs\win32-g++" -o debug\COperationWIndow.o COperationWIndow.cpp
    6. ../../../../Qt/4.3.4/include/QtCore/../../src/corelib/kernel/qvariant.h: In member function `void COperationWIndow::chooseMerchandize()':
    7. ../../../../Qt/4.3.4/include/QtCore/../../src/corelib/kernel/qvariant.h:415: error: `QVariant::QVariant(bool, int)' is private
    8. COperationWIndow.cpp:284: error: within this context
    9. mingw32-make[1]: *** [debug/COperationWIndow.o] Error 1
    10. mingw32-make[1]: Leaving directory `C:/Documents and Settings/markofr/workspace/Client'
    11. mingw32-make: *** [debug] Error 2
    To copy to clipboard, switch view to plain text mode 
    The very similiar line of code from example works fine. Why?!
    Well, my mistake again, I did not take a look at this line of code carefully, sorry for this spamming post ...
    Qt 5.3 Opensource & Creator 3.1.2

  7. #7
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Unhappy Re: QTableWidget problem

    Ok, we are getting somewhere with this widget, but now I encountered a problem. So, I this main window class declaration I have:
    Qt Code:
    1. CShoppingCartView* m_pShoppingCartView;
    To copy to clipboard, switch view to plain text mode 
    In class CShoppingCart I have a pointer to internal order class:
    Qt Code:
    1. CMerchandizeOrder* m_pOrder;
    To copy to clipboard, switch view to plain text mode 
    and corresponding inline function:
    Qt Code:
    1. inline CMerchandizeOrder* order()
    2. { return m_pOrder; };
    To copy to clipboard, switch view to plain text mode 
    Now, when I call:
    Qt Code:
    1. m_pShoppingCartView->order()->orders().append(tmpOrder); // adds order to internal qlist
    2. int iOrderSize=m_pShoppingCartView->order()->orders().size(); // calcs size
    3. Q_ASSERT_X(iOrderSize>0, "COperationWindow.cpp", "m_pShoppingCartView->order()->orders().size()<0"); // checks size
    To copy to clipboard, switch view to plain text mode 
    I get assert failure, so struct is not added to list. I do not know why, please help!!! I've doublechecked if I create qlist of orders and I do it in constructor, so that part is ok. Please help!
    Qt 5.3 Opensource & Creator 3.1.2

Similar Threads

  1. Replies: 3
    Last Post: 11th August 2007, 10:00
  2. experiencing problem at printing out QTableWidget
    By rmagro in forum Qt Programming
    Replies: 9
    Last Post: 27th June 2007, 16:04
  3. QTableWidget Problem, setRowWidget? :P
    By VireX in forum Newbie
    Replies: 17
    Last Post: 6th April 2007, 18:12
  4. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 18:46
  5. Problem inserting in QTableWidget
    By DPinLV in forum Qt Programming
    Replies: 2
    Last Post: 2nd August 2006, 00:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.