Page 3 of 3 FirstFirst 123
Results 41 to 54 of 54

Thread: QTableWidget problem

  1. #41
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableWidget problem

    Resize won't work as layouts override it. Use what I suggested.

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

    Default Re: QTableWidget problem

    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

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

    Default Re: QTableWidget problem

    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.

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

    Default Re: QTableWidget problem

    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

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

    Default Re: QTableWidget problem

    Quote Originally Posted by MarkoSan View Post
    Yes, wysota, do not be mad, please, you are right, but I haven't slept whole weekend because of this application.
    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.

    And I do not use designer,
    Those same names are available in Qt Assistant.

    since I want to master qt by handcoding and then switch to designer ....
    Bad idea.

  6. The following user says thank you to wysota for this useful post:

    MarkoSan (14th April 2008)

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

    Default Re: QTableWidget problem

    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

  8. #47
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableWidget problem

    No, I told you to use different roles for different data pieces.

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

    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

  10. #49
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    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?

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

    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

  12. #51
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableWidget problem

    For each data piece you need one role.

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

    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

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

    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

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

    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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.