Задать размер выпадающего списка у QComboBox.
Туплю слегонца.....
Проблема на скрине:
void uoReportPropEditor::addColor(int& row, QColor col, bool def)
{
m_colorModel->insertRows(row, 1, QModelIndex());
m_colorModel->setData(m_colorModel->index(row, 0, QModelIndex()),col);
m_colorModel->setData(m_colorModel->index(row, 0, QModelIndex()),col, Qt::DecorationRole);
}
void uoReportPropEditor::fillColorModel()
{
m_colorModel->removeRows(0, m_colorModel->rowCount(QModelIndex()), QModelIndex());
int row = -1;
addColor(++row, QColor("#000000"), true);
addColor(++row, QColor("#ffffff"), true);
addColor(++row, QColor("#ff0000"), true);
addColor(++row, QColor("#00ff00"), true);
addColor(++row, QColor("#0000ff"), true);//blue
addColor(++row, QColor("#ffff00"), true);// желтый
addColor(++row, QColor("#ff00ff"), true); //
addColor(++row, QColor("#00ffff"), true); //
addColor(++row, QColor("#800000"), true); //
addColor(++row, QColor("#008000"), true); //
addColor(++row, QColor("#808000"), true); //
addColor(++row, QColor("#000080"), true); //
addColor(++row, QColor("#800080"), true); //
addColor(++row, QColor("#008080"), true); //
addColor(++row, QColor("#808080"), true); //
addColor(++row, QColor("#c0c0c0"), true); //
//3
addColor(++row, QColor("#8080ff"), true); //
addColor(++row, QColor("#802060"), true); //
addColor(++row, QColor("#ffffc0"), true); //
addColor(++row, QColor("#a0e0e0"), true); //
addColor(++row, QColor("#600080"), true); //
addColor(++row, QColor("#ff8080"), true); //
addColor(++row, QColor("#0080c0"), true); //
addColor(++row, QColor("#c0c0ff"), true); //
//4
addColor(++row, QColor("#00cfff"), true); //
addColor(++row, QColor("#69ffff"), true); //
addColor(++row, QColor("#e0ffe0"), true); //
addColor(++row, QColor("#dd9cb3"), true); //
addColor(++row, QColor("#b38fee"), true); //
addColor(++row, QColor("#2a6ff9"), true); //
addColor(++row, QColor("#3fb8cd"), true); //
addColor(++row, QColor("#488436"), true); //
// 5
addColor(++row, QColor("#958c41"), true); //
addColor(++row, QColor("#905e42"), true); //
addColor(++row, QColor("#a0627a"), true); //
addColor(++row, QColor("#624fac"), true); //
addColor(++row, QColor("#1d2fbe"), true); //
addColor(++row, QColor("#286676"), true); //
addColor(++row, QColor("#004500"), true); //
addColor(++row, QColor("#453e01"), true); //
// 6
addColor(++row, QColor("#6a2813"), true); //
addColor(++row, QColor("#85396a"), true); //
addColor(++row, QColor("#4a3285"), true); //
addColor(++row, QColor("#c0dcc0"), true); //
addColor(++row, QColor("#a6caf0"), true); //
addColor(++row, QColor("#7fffd4"), true); //
addColor(++row, QColor("#f0ffff"), true); //
addColor(++row, QColor("#f5f5dc"), true); ///// Повтор?!
// Повторы?!
// 7
addColor(++row, QColor("#808000"), true); //
addColor(++row, QColor("#800080"), true); //
addColor(++row, QColor("#008080"), true); //
addColor(++row, QColor("#808080"), true); //
addColor(++row, QColor("#fffbf0"), true); //
addColor(++row, QColor("#a0a0a4"), true); //
addColor(++row, QColor("#313900"), true); //
addColor(++row, QColor("#d9853e"), true); //
}
view->updateGeometry();
void QWidget::mousePressEvent(QMouseEvent *event)
{
event->ignore();
if ((windowType() == Qt::Popup)) {
event->accept();
QWidget* w;
while ((w = qApp->activePopupWidget()) && w != this){
w->close();
if (qApp->activePopupWidget() == w) // widget does not want to dissappear
w->hide(); // hide at least
}
if (!rect().contains(event->pos())){
close();
}
}
}
void QComboBoxPrivateContainer::mousePressEvent(QMouseEvent *e)
{
QStyleOptionComboBox opt = comboStyleOption();
opt.subControls = QStyle::SC_All;
opt.activeSubControls = QStyle::SC_ComboBoxArrow;
QStyle::SubControl sc = combo->style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt,
combo->mapFromGlobal(e->globalPos()),
combo);
if ((combo->isEditable() && sc == QStyle::SC_ComboBoxArrow)
|| (!combo->isEditable() && sc != QStyle::SC_None))
setAttribute(Qt::WA_NoMouseReplay);
combo->hidePopup();
}
QObject::connect(btnOK, SIGNAL(clicked()),colCh, SLOT(popupShow()));
setWindowFlags(Qt::ToolTip);
QWidget::mousePressEvent(event);
void uoColorCContainer::mousePressEvent(QMouseEvent *event)
{
QPoint pt = event->pos();
QList<uoColRect>::const_iterator cIt = m_colRects.begin();
uoColRect colrRct;
int cur = 0;
while(cIt != m_colRects.end()){
colrRct = *cIt;
if (colrRct.m_rect.contains(pt))
{
m_curentItem = cur;
cur = -1;
break;
}
cIt++;
++cur;
}
if (cur == -1){
setCurentItem(m_curentItem);
hide();
}
QWidget::mousePressEvent(event);
}
void uoColorChooser::popupShow()
{
if (m_colorList.isEmpty())
return;
getContainer();
QSize sz = m_Container->recalcSize();
m_Container->doChangeCurColor(m_colorCurPos);
QPoint below = mapToGlobal(frameRect().bottomLeft());
QRect contRect = QRect(below, QPoint(below.x()+sz.width(), below.y()+sz.height()));
m_Container->setGeometry(contRect);
m_Container->move(below);
m_Container->raise();
m_Container->show();
m_Container->update();
m_Container->setFocus();
}