QSqlRelationalDelegate Draw a clickable QToolButton
How i can draw a rect 22x22 to make clickabel && emit a signal to parent QWidget
like a ....
QPixmap pix(22, 22);
pix.fill(normalcolor); ... ?
I tested to put in direct a QToolButton but loop to infinite..... and is a setIndexWidget....
Code:
{
/////////qDebug() << "### index-column " << index.column();
if (index.column() == 0) {
/* not on edit only flags |= Qt::ItemIsSelectable; */
QString numer
= index.
model()->data
(index, Qt
::DisplayRole).
toString();
button1->setText(text);
tas->setIndexWidget(index,button1);
} else if (index.column() == 1) {
/* not on edit only flags |= Qt::ItemIsSelectable; */
QString coder
= index.
model()->data
(index, Qt
::DisplayRole).
toString();
myOption.displayAlignment = Qt::AlignLeft | Qt::AlignVCenter;
myOption.
palette.
setColor( QPalette::Text , Qt
::red );
drawDisplay(painter, myOption, myOption.rect,coder);
drawFocus(painter, myOption, myOption.rect);
}
...............
}
/* header */
{
Q_OBJECT
public:
private slots:
private:
};
Re: QSqlRelationalDelegate Draw a clickable QToolButton
Your code doesn't make sense. Why do you create a tool button in every repaint of the cell? If you want to draw a tool button, then use QStyle::drawComplexControl() with CC_ToolButton as its parameter.
What are you trying to do exactly?
Re: QSqlRelationalDelegate Draw a clickable QToolButton
Quote:
Originally Posted by
wysota
Your code doesn't make sense. Why do you create a tool button in every repaint of the cell? If you want to
draw a tool button, then use
QStyle::drawComplexControl() with CC_ToolButton as its parameter.
What are you trying to do exactly?
i have 11 cell on my table only 9 ist editable from model .... and one cell wo is not editable.. i must make a link (connect) to to edit moore field in a form.... and a symple doupleclick is not inaf ..... or i draw a button inside or a qpixmap buttonstyle to append event ... wo people understand to click ,,, && open other dialog.....
I search drawComplexControl i found only a small piece code.... on
http://www.koders.com/cpp/fidE11AA04...ComplexControl
How i can integrate to my model .....?
is this a pain event from QSqlRelationalDelegate subclass?
Code:
{
if ( testWFlags( WStyle_SysMenu) ) {
if ( testWFlags( WStyle_Tool ) ) {
ctrls |
= QStyle::SC_TitleBarCloseButton;
if ( d->window && testWFlags( WStyle_MinMax ) ) {
if ( d->window->isMinimized() )
ctrls |
= QStyle::SC_TitleBarUnshadeButton;
else
ctrls |
= QStyle::SC_TitleBarShadeButton;
}
} else {
ctrls |
= QStyle::SC_TitleBarSysMenu |
QStyle::SC_TitleBarCloseButton;
if ( d->window && testWFlags( WStyle_Minimize ) ) {
if( d->window && d->window->isMinimized() )
ctrls |
= QStyle::SC_TitleBarNormalButton;
else
ctrls |
= QStyle::SC_TitleBarMinButton;
}
if ( d->window && testWFlags( WStyle_Maximize ) && !d->window->isMaximized() )
ctrls |
= QStyle::SC_TitleBarMaxButton;
}
}
if( autoRaise() && hasMouse() ) {
under_mouse
= style
().
querySubControl(QStyle::CC_TitleBar,
this, p
);
ctrls ^= under_mouse;
}
QSharedDoubleBuffer buffer( this, rect() );
style
().
drawComplexControl(QStyle::CC_TitleBar, buffer.
painter(),
this, rect
(),
colorGroup(),
isEnabled
() ?
QStyle::Style_Enabled : QStyle::Style_Default, ctrls, d
->buttonDown
);
if(under_mouse
!= QStyle::SC_None) style
().
drawComplexControl(QStyle::CC_TitleBar, buffer.
painter(),
this, rect
(),
colorGroup(),
(isEnabled
() ?
QStyle::Style_Enabled : 0),
under_mouse, d->buttonDown);
}
Note:
I have commit my code on http://sourceforge.net/projects/qt-webdav/ much tanks to wysota to make this projekt possibel.... the svn code is live update....
Re: QSqlRelationalDelegate Draw a clickable QToolButton
Why don't you just create an editor widget and assign it to the delegate for appropriate fields?
Re: QSqlRelationalDelegate Draw a clickable QToolButton
Quote:
Originally Posted by
wysota
Why don't you just create an editor widget and assign it to the delegate for appropriate fields?
An createEditor subclass .... is only to editable flag? or i write mistake?
i can test to emulate a Qt::ItemIsEditable; and return true (on set data ) to column 0 (zero) in this place wo i wand click action ....
Code:
{
if (index.column() == 11 || index.column() == 7 ) {
editor->setDisplayFormat("dd.MM.yyyy");
editor->setCalendarPopup(true);
return editor;
} else {
}
}
{
if (index.column() == 11 || index.column() == 7 ) {
QString dateuser
= index.
model()->data
(index, Qt
::DisplayRole).
toString();
QDateTimeEdit *editorrun
= qobject_cast<QDateTimeEdit
*>
(editor
);
if (editorrun) {
editorrun
->setDate
(QDate::fromString(index.
model()->data
(index, Qt
::EditRole).
toString(),
"dd.MM.yyyy"));
}
} else {
}
}
note: code paste from gedit not from scite \n\n buggi scite?
Help why i become "Advanced user" ?? :crying: i am advanced user on PHP5 Objekt programming , xml, xslt .... latex... but not on qt4.... on qt4 i preferred Intermediate....:rolleyes:
Re: QSqlRelationalDelegate Draw a clickable QToolButton
Quote:
Originally Posted by
patrik08
An createEditor subclass .... is only to editable flag? or i write mistake?
Yes and no. Under normal circumstances it is only for editable items but you can also open something what is called a persistent editor. It is an editor that is always active, regardless of the item focus.
Quote:
i can test to emulate a Qt::ItemIsEditable; and return true (on set data ) to column 0 (zero) in this place wo i wand click action ....
I don't understand what you mean.
Quote:
note: code paste from gedit not from scite \n\n buggi scite?
Again, I can't understand you.
Quote:
Help why i become "Advanced user" ??
Because you post too much :)