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 ...
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
I see different pieces of data here, don't you?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
So, quote fomr the docs:So, for this each data from struct I need a whole familiy of this roles (numbers)?!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.
Qt 5.3 Opensource & Creator 3.1.2
For each data piece you need one role.
Ok, I am slowly getting somewhere, but in the statement:Qt Code:
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:
mingw32-make mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory `C:/Documents and Settings/markofr/workspace/Client' 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 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 ../../../../Qt/4.3.4/include/QtCore/../../src/corelib/kernel/qvariant.h: In member function `void COperationWIndow::chooseMerchandize()': COperationWIndow.cpp:284: error: within this context mingw32-make[1]: *** [debug/COperationWIndow.o] Error 1 mingw32-make[1]: Leaving directory `C:/Documents and Settings/markofr/workspace/Client' mingw32-make: *** [debug] Error 2To 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
Ok, we are getting somewhere with this widget, but now I encountered a problem. So, I this main window class declaration I have:In class CShoppingCart I have a pointer to internal order class:Qt Code:
CShoppingCartView* m_pShoppingCartView;To copy to clipboard, switch view to plain text modeand corresponding inline function:Qt Code:
CMerchandizeOrder* m_pOrder;To copy to clipboard, switch view to plain text modeNow, when I call:Qt Code:
inline CMerchandizeOrder* order() { return m_pOrder; };To copy to clipboard, switch view to plain text modeI 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 Code:
m_pShoppingCartView->order()->orders().append(tmpOrder); // adds order to internal qlist int iOrderSize=m_pShoppingCartView->order()->orders().size(); // calcs size Q_ASSERT_X(iOrderSize>0, "COperationWindow.cpp", "m_pShoppingCartView->order()->orders().size()<0"); // checks sizeTo copy to clipboard, switch view to plain text mode
Qt 5.3 Opensource & Creator 3.1.2
Bookmarks