Results 1 to 3 of 3

Thread: Custom item widgets are flat.

  1. #1
    Join Date
    Nov 2013
    Posts
    5
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11

    Post Custom item widgets are flat.

    I have a class which is custom widget for QTableWidgetItem. Using Qt 4.8 everything was OK, but in Qt 5.2.1 there is a problem.

    My widget class:
    Qt Code:
    1. class QTableCalendarWidget: public QWidget
    2. {
    3. Q_OBJECT
    4. public:
    5. QTableCalendarWidget(QString ToolTip,bool Ev,bool BDay)
    6. {
    7. Date=QDate::fromString(ToolTip,"d/MM/yyyy");
    8. Event=new QLabel(this);
    9. Birth=new QLabel(this);
    10. Label=new QLabel(QString::number(Date.day()),this);
    11. Add=new QPushButton(this);
    12. QPixmap w=QPixmap(12,12);
    13. w.fill(Qt::transparent);
    14. if(Ev)
    15. {
    16. Event->setPixmap(QIcon(":/cal/Ev").pixmap(15));
    17. }
    18. else
    19. {
    20. Event->setPixmap(w);
    21. }
    22. if(BDay)
    23. {
    24. Birth->setPixmap(QIcon(":/cal/BDay").pixmap(15));
    25. }
    26. else
    27. {
    28. Birth->setPixmap(w);
    29. }
    30. Label->setAlignment(Qt::AlignHCenter);
    31. Add->setStyleSheet("QPushButton {border: 0px solid white;}");
    32. Add->setIcon(QIcon(w));
    33. Add->setDisabled(true);
    34. connect(Add,SIGNAL(clicked()),this,SLOT(addIN()));
    35. QHBoxLayout *Layout=new QHBoxLayout();
    36. Layout->setSpacing(1);
    37. Layout->addWidget(Event);
    38. Layout->addWidget(Birth);
    39. Layout->addWidget(Label,Qt::AlignHCenter);
    40. Layout->addWidget(Add);
    41. this->setLayout(Layout);
    42. }
    43. void AddB()
    44. {
    45. Add->setEnabled(true);
    46. Add->setIcon(QIcon(QIcon(":/main/Add").pixmap(12,12)));
    47. }
    48. private:
    49. QDate Date;
    50. QLabel *Event;
    51. QLabel *Birth;
    52. QLabel *Label;
    53. private slots:
    54. void addIN()
    55. {
    56. emit addOUT(Date);
    57. }
    58. signals:
    59. void addOUT(QDate);
    60. };
    To copy to clipboard, switch view to plain text mode 

    I am setting widget this way:
    Qt Code:
    1. QTableCalendarWidget *Day=new QTableCalendarWidget(Items[i]->toolTip(),Ev,Bd);
    2. Calendar->setCellWidget(Items[i]->row(),Items[i]->column(),Day);
    To copy to clipboard, switch view to plain text mode 
    Where Items[i] is QTableWidgetItem already added to QTableWidget, with date as a ToolTip.

    The appearance:zrzut ekranu2.png

    As all of you can see the custom widget is flat. Standard QTableWidgetItem is visible normally.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,552
    Thanks
    13
    Thanked 1,579 Times in 1,508 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Custom item widgets are flat.

    What do you mean by "the custom widget is flat"?

  3. #3
    Join Date
    Nov 2013
    Posts
    5
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Custom item widgets are flat.

    The widget is 1 px high. In previous version widget height was a cell height. Is there any way of changing it without calling resize()? Resizing cause that text is out of cell.

Similar Threads

  1. Replies: 1
    Last Post: 18th July 2012, 09:59
  2. Replies: 0
    Last Post: 30th April 2012, 15:17
  3. Replies: 5
    Last Post: 10th August 2009, 10:50
  4. Replies: 0
    Last Post: 15th May 2009, 15:38
  5. QTreeWidget's Item Widgets
    By jpn in forum Qt Programming
    Replies: 11
    Last Post: 1st April 2006, 23:56

Tags for this Thread

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.