Resize won't work as layouts override it. Use what I suggested.
Resize won't work as layouts override it. Use what I suggested.
well, if I knew what you thought I would not be asking now ... Will go now read docs, thanks for hints and tips, wysota...
Qt 5.3 Opensource & Creator 3.1.2
I told you the names of fields in Designer. I think I can expect someone with at least two years of experience to locate them there.
Yes, wysota, do not be mad, please, you are right, but I haven't slept whole weekend because of this application. And I do not use designer, since I want to master qt by handcoding and then switch to designer ....
Qt 5.3 Opensource & Creator 3.1.2
So now you see this was not a good idea. A tired man (programmers included) has a very reduced efficiency. A very tired man has no efficiency at all. Go to sleep.
Those same names are available in Qt Assistant.And I do not use designer,
Bad idea.since I want to master qt by handcoding and then switch to designer ....
MarkoSan (14th April 2008)
Well, ok, now I've set up all things as they should be. I've subclassed QTableView and QAbstractTableModel. It works fine for now. Just question. I've followed wysota's advice and the method data() return QVariant, which is QString stuffed with the values of all components of my struct. Wysota, did I do it right way or not?
Qt 5.3 Opensource & Creator 3.1.2
No, I told you to use different roles for different data pieces.
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