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
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QTableWidget problem

    Hi to all!

    I need to develop an subclassed table widget, which will look something like that:
    Qt Code:
    1. +===================================+
    2. + Coca Cola +
    3. + 1,50 EUR 002 3,00 EUR +
    4. + Sprite +
    5. + 1,30 EUR 010 13,00 EUR +
    6. + Cheeseburger with salad +
    7. + 3,80 EUR 004 15,20 EUR +
    8. + Beefstake with potato and salad +
    9. + 24,67 EUR 012 296,04 EUR +
    10. +===================================+
    11. + TOTAL: 327,24 EUR +
    12. +===================================+
    To copy to clipboard, switch view to plain text mode 
    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

    Does someone has any idea how to achieve that?!
    Qt 5.3 Opensource & Creator 3.1.2

  2. #2
    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

    Have you already tried anything?

  3. #3
    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

    No, I need a few hints how to make two lines in a cell. Then I will begin.
    Qt 5.3 Opensource & Creator 3.1.2

  4. #4
    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

    Add a newline character to the string displayed.

  5. #5
    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, I am not total idiot. I need a cell, which is constructed from:
    • upper string line
    • and lower line, which is constructed from
      • price/unit string line and eur icon - left formatted
      • quantity string line (with leading zeros)
      • price/unit*quantity string line and eur icon - right formatted
    I cannot solve this with newline character.
    Qt 5.3 Opensource & Creator 3.1.2

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget problem

    Well, why cant u have the brand name as column ? why need it as row ??

    I am not sure of this will work... but hers my idea..
    U can use delegates to have each cell as a widget. This widget has two rows... first the name, second the pprice, quantity etc.

    hope it helps

  7. #7
    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

    I am limited with table's width, it is critical to minimize table's width because the neighbour widget must take the largest size possible because of data representation.
    Qt 5.3 Opensource & Creator 3.1.2

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTableWidget problem

    So, what prevents you from using multiple columns? You'll get nice alignment out of the box. Besides, I'd use tree view instead of table view.
    J-P Nurmi

  9. #9
    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 jpn View Post
    So, what prevents you from using multiple columns? You'll get nice alignment out of the box. Besides, I'd use tree view instead of table view.
    Tree view is clumsy for touch screen user interaction. I've tried it before and because of fu... users I had to recode tree view into representation I want to do now in Qt. The same solution worked in Clarion for Windows.

    Quote Originally Posted by THRESHE View Post
    You can create a layout on a widget wich has the strings that you said and icons and then set this widget as a cell widget. Though it can be slow...

    The other way is to implement a delegate and draw your cell there
    So. thanks for guideline, I will get to read docs about delegates ASAP.
    Qt 5.3 Opensource & Creator 3.1.2

  10. #10
    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, now I have developec merchandize order class. What do I need to do to get the requested form in delegate? Reimplement the paintEvent()?? Or what?
    Qt 5.3 Opensource & Creator 3.1.2

  11. #11
    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, I am slowly managing to get somewhere with my problem. Now, how do I translate the table cell (which has QString, qreal, qint16 and another qreal) from the first post into QVariant type? And how do I transfrom this cell into single QString?
    Qt 5.3 Opensource & Creator 3.1.2

  12. #12
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QTableWidget problem

    You can create a layout on a widget wich has the strings that you said and icons and then set this widget as a cell widget. Though it can be slow...

    The other way is to implement a delegate and draw your cell there
    C++ & AMD forever

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.