Thank you anda_skoam, your last tips solved all problems.

I have one more question: d-pointers should be limited to libraries or is good habit to use them in normal apps, too?

Regards.

P.S.
Here it is final code, if useful to others:

mywidget_p.h
Qt Code:
  1. #ifndef MYWIDGET_P_H
  2. #define MYWIDGET_P_H
  3.  
  4. #include "mywidget.h"
  5. #include "ui_mywidget.h"
  6.  
  7. namespace Ui {
  8. class MyWidget;
  9. }
  10.  
  11. class MyWidgetPrivate
  12. {
  13. MyWidget * const q; // not stricly necessary, just in case you put methods into MyWidgetPrivate that need access to MyWidget
  14.  
  15. public:
  16. explicit MyWidgetPrivate( MyWidget *parent ) :
  17. q( parent ), ui( new Ui::MyWidget )
  18. {
  19. ui->setupUi( parent );
  20. }
  21.  
  22. Ui::MyWidget *ui;
  23.  
  24. QString first;
  25. QString second;
  26. };
  27.  
  28. #endif // MYWIDGET_P_H
To copy to clipboard, switch view to plain text mode 

mywidget.h
Qt Code:
  1. #ifndef MYWIDGET_H
  2. #define MYWIDGET_H
  3.  
  4. #include <QWidget>
  5.  
  6. class MyWidgetPrivate;
  7.  
  8. class MyWidget : public QWidget
  9. {
  10. Q_OBJECT
  11. Q_PROPERTY(QString first READ first WRITE setFirst)
  12. Q_PROPERTY(QString second READ second WRITE setSecond)
  13.  
  14. public:
  15. explicit MyWidget(const QString &first,
  16. const QString &second,
  17. QWidget *parent = 0);
  18. ~MyWidget();
  19.  
  20. QString first() const;
  21. void setFirst(const QString);
  22. QString second() const;
  23. void setSecond(const QString);
  24.  
  25. private:
  26. MyWidgetPrivate * const d;
  27. };
  28.  
  29. #endif // MYWIDGET_H
To copy to clipboard, switch view to plain text mode 

mywidget.cpp
Qt Code:
  1. #include "mywidget_p.h"
  2.  
  3. MyWidget::MyWidget(const QString &first, const QString &second, QWidget *parent) :
  4. QWidget(parent),
  5. d( new MyWidgetPrivate( this ) )
  6. {
  7. d->first = first;
  8. d->second = second;
  9. }
  10.  
  11. MyWidget::~MyWidget()
  12. {
  13. delete d;
  14. }
  15.  
  16. QString MyWidget::first() const
  17. {
  18. return d->first;
  19. }
  20.  
  21. void MyWidget::setFirst(const QString text)
  22. {
  23. d->first = text;
  24. }
  25.  
  26. QString MyWidget::second() const
  27. {
  28. return d->second;
  29. }
  30.  
  31. void MyWidget::setSecond(const QString text)
  32. {
  33. d->second = text;
  34. }
To copy to clipboard, switch view to plain text mode