Results 1 to 4 of 4

Thread: Problem with custom widget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Problem with custom widget

    It probably creates the right object, but your custom widget is wrong.

    It should be:
    Qt Code:
    1. class SpreadSheet : public QTableWidget
    2. {
    3. Q_OBJECT
    4. public :
    5. SpreadSheet( QWidget* a_parent = 0 );
    6. SpreadSheet( int a_row = 1, int a_column = 4, QWidget *a_parent = 0 );
    7. void CreatePopupMenu();
    8.  
    9. private slots:
    10. void ChooseColor();
    11. void ExecPopupMenu( int, int );
    12.  
    13. private:
    14. unsigned row;
    15. unsigned column;
    16. Q3PopupMenu *menu;
    17. QAction *colorBackAct;
    18. QAction *colorTextAct;
    19. QColor color;
    20. };
    To copy to clipboard, switch view to plain text mode 
    PS. Next time, please, use [ code ] tags to make your code readable.

  2. #2
    Join Date
    Feb 2006
    Posts
    32
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    3

    Default Re: Problem with custom widget

    Thanks,

    I was thinking Q_OBJECT macro is used for Signals and Slots.

    I have one more doubt about width and height of each cell in QTableWidget. Except using methods like setColumnWidth(), setRowHeight(), is there any function which will create all cell of same width and height.

    Thanks
    Jnana

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Problem with custom widget

    Quote Originally Posted by jnana
    I was thinking Q_OBJECT macro is used for Signals and Slots.
    It is, but the problem was that you didn't declare ChooseColor() and ExecPopupMenu( int, int ) as slots.

    Quote Originally Posted by jnana
    Except using methods like setColumnWidth(), setRowHeight(), is there any function which will create all cell of same width and height.
    You could try changing the size hint for QTableWidgetItems.

Similar Threads

  1. Widget background problem.
    By zgulser in forum Qt Tools
    Replies: 2
    Last Post: 6th January 2009, 06:34
  2. custom plug-in widget in another custom plug-in widget.
    By MrGarbage in forum Qt Programming
    Replies: 6
    Last Post: 27th August 2007, 15:38
  3. Simple custom widget won't size properly
    By MrGarbage in forum Qt Tools
    Replies: 2
    Last Post: 9th August 2007, 13:12
  4. Custom tab widget question
    By PrimeCP in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 11:17
  5. Replies: 4
    Last Post: 1st March 2006, 23:11

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.