A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B%2FQt%2FQComboBox</id>
		<title>C++/Qt/QComboBox - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B%2FQt%2FQComboBox"/>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B/Qt/QComboBox&amp;action=history"/>
		<updated>2026-04-10T03:36:23Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B/Qt/QComboBox&amp;diff=1208&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B/Qt/QComboBox&amp;diff=1208&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:06Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:21, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B/Qt/QComboBox&amp;diff=1209&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B/Qt/QComboBox&amp;diff=1209&amp;oldid=prev"/>
				<updated>2010-05-25T10:25:08Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Color list editor==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
/****************************************************************************&lt;br /&gt;
**&lt;br /&gt;
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).&lt;br /&gt;
** All rights reserved.&lt;br /&gt;
** Contact: Nokia Corporation (qt-info@nokia.com)&lt;br /&gt;
**&lt;br /&gt;
** This file is part of the examples of the Qt Toolkit.&lt;br /&gt;
**&lt;br /&gt;
** $QT_BEGIN_LICENSE:LGPL$&lt;br /&gt;
** Commercial Usage&lt;br /&gt;
** Licensees holding valid Qt Commercial licenses may use this file in&lt;br /&gt;
** accordance with the Qt Commercial License Agreement provided with the&lt;br /&gt;
** Software or, alternatively, in accordance with the terms contained in&lt;br /&gt;
** a written agreement between you and Nokia.&lt;br /&gt;
**&lt;br /&gt;
** GNU Lesser General Public License Usage&lt;br /&gt;
** Alternatively, this file may be used under the terms of the GNU Lesser&lt;br /&gt;
** General Public License version 2.1 as published by the Free Software&lt;br /&gt;
** Foundation and appearing in the file LICENSE.LGPL included in the&lt;br /&gt;
** packaging of this file.  Please review the following information to&lt;br /&gt;
** ensure the GNU Lesser General Public License version 2.1 requirements&lt;br /&gt;
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.&lt;br /&gt;
**&lt;br /&gt;
** In addition, as a special exception, Nokia gives you certain additional&lt;br /&gt;
** rights.  These rights are described in the Nokia Qt LGPL Exception&lt;br /&gt;
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.&lt;br /&gt;
**&lt;br /&gt;
** GNU General Public License Usage&lt;br /&gt;
** Alternatively, this file may be used under the terms of the GNU&lt;br /&gt;
** General Public License version 3.0 as published by the Free Software&lt;br /&gt;
** Foundation and appearing in the file LICENSE.GPL included in the&lt;br /&gt;
** packaging of this file.  Please review the following information to&lt;br /&gt;
** ensure the GNU General Public License version 3.0 requirements will be&lt;br /&gt;
** met: http://www.gnu.org/copyleft/gpl.html.&lt;br /&gt;
**&lt;br /&gt;
** If you have questions regarding the use of this file, please contact&lt;br /&gt;
** Nokia at qt-info@nokia.com.&lt;br /&gt;
** $QT_END_LICENSE$&lt;br /&gt;
**&lt;br /&gt;
****************************************************************************/&lt;br /&gt;
#ifndef COLORLISTEDITOR_H&lt;br /&gt;
#define COLORLISTEDITOR_H&lt;br /&gt;
#include &amp;lt;QComboBox&amp;gt;&lt;br /&gt;
QT_BEGIN_NAMESPACE&lt;br /&gt;
class QColor;&lt;br /&gt;
class QWidget;&lt;br /&gt;
QT_END_NAMESPACE&lt;br /&gt;
&lt;br /&gt;
class ColorListEditor : public QComboBox&lt;br /&gt;
{&lt;br /&gt;
    Q_OBJECT&lt;br /&gt;
    Q_PROPERTY(QColor color READ color WRITE setColor USER true)&lt;br /&gt;
public:&lt;br /&gt;
    ColorListEditor(QWidget *widget = 0);&lt;br /&gt;
public:&lt;br /&gt;
    QColor color() const;&lt;br /&gt;
    void setColor(QColor c);&lt;br /&gt;
private:&lt;br /&gt;
    void populateList();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;QtGui&amp;gt;&lt;br /&gt;
#include &amp;quot;colorlisteditor.h&amp;quot;&lt;br /&gt;
ColorListEditor::ColorListEditor(QWidget *widget) : QComboBox(widget)&lt;br /&gt;
{&lt;br /&gt;
    populateList();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
QColor ColorListEditor::color() const&lt;br /&gt;
{&lt;br /&gt;
    return qVariantValue&amp;lt;QColor&amp;gt;(itemData(currentIndex(), Qt::DecorationRole));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void ColorListEditor::setColor(QColor color)&lt;br /&gt;
{&lt;br /&gt;
    setCurrentIndex(findData(color, int(Qt::DecorationRole)));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void ColorListEditor::populateList()&lt;br /&gt;
{&lt;br /&gt;
    QStringList colorNames = QColor::colorNames();&lt;br /&gt;
    for (int i = 0; i &amp;lt; colorNames.size(); ++i) {&lt;br /&gt;
        QColor color(colorNames[i]);&lt;br /&gt;
        insertItem(i, colorNames[i]);&lt;br /&gt;
        setItemData(i, color, Qt::DecorationRole);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#ifndef WINDOW_H&lt;br /&gt;
#define WINDOW_H&lt;br /&gt;
#include &amp;lt;QWidget&amp;gt;&lt;br /&gt;
class Window : public QWidget&lt;br /&gt;
{&lt;br /&gt;
    Q_OBJECT&lt;br /&gt;
public:&lt;br /&gt;
    Window();&lt;br /&gt;
private:&lt;br /&gt;
    void createGUI();&lt;br /&gt;
};&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;QtGui&amp;gt;&lt;br /&gt;
#include &amp;quot;window.h&amp;quot;&lt;br /&gt;
#include &amp;quot;colorlisteditor.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Window::Window()&lt;br /&gt;
{&lt;br /&gt;
    QItemEditorFactory *factory = new QItemEditorFactory;&lt;br /&gt;
    QItemEditorCreatorBase *colorListCreator =&lt;br /&gt;
        new QStandardItemEditorCreator&amp;lt;ColorListEditor&amp;gt;();&lt;br /&gt;
    factory-&amp;gt;registerEditor(QVariant::Color, colorListCreator);&lt;br /&gt;
    QItemEditorFactory::setDefaultFactory(factory);&lt;br /&gt;
    createGUI();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Window::createGUI()&lt;br /&gt;
{&lt;br /&gt;
    QList&amp;lt;QPair&amp;lt;QString, QColor&amp;gt; &amp;gt; list;&lt;br /&gt;
    list &amp;lt;&amp;lt; QPair&amp;lt;QString, QColor&amp;gt;(tr(&amp;quot;Alice&amp;quot;), QColor(&amp;quot;aliceblue&amp;quot;)) &amp;lt;&amp;lt;&lt;br /&gt;
            QPair&amp;lt;QString, QColor&amp;gt;(tr(&amp;quot;Neptun&amp;quot;), QColor(&amp;quot;aquamarine&amp;quot;)) &amp;lt;&amp;lt;&lt;br /&gt;
            QPair&amp;lt;QString, QColor&amp;gt;(tr(&amp;quot;Ferdinand&amp;quot;), QColor(&amp;quot;springgreen&amp;quot;));&lt;br /&gt;
    QTableWidget *table = new QTableWidget(3, 2);&lt;br /&gt;
    table-&amp;gt;setHorizontalHeaderLabels(QStringList() &amp;lt;&amp;lt; tr(&amp;quot;Name&amp;quot;)&lt;br /&gt;
                                                   &amp;lt;&amp;lt; tr(&amp;quot;Hair Color&amp;quot;));&lt;br /&gt;
    table-&amp;gt;verticalHeader()-&amp;gt;setVisible(false);&lt;br /&gt;
    table-&amp;gt;resize(150, 50);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 3; ++i) {&lt;br /&gt;
        QPair&amp;lt;QString, QColor&amp;gt; pair = list.at(i);&lt;br /&gt;
        QTableWidgetItem *nameItem = new QTableWidgetItem(pair.first);&lt;br /&gt;
        QTableWidgetItem *colorItem = new QTableWidgetItem;&lt;br /&gt;
        colorItem-&amp;gt;setData(Qt::DisplayRole, pair.second);&lt;br /&gt;
        table-&amp;gt;setItem(i, 0, nameItem);&lt;br /&gt;
        table-&amp;gt;setItem(i, 1, colorItem);&lt;br /&gt;
    }&lt;br /&gt;
    table-&amp;gt;resizeColumnToContents(0);&lt;br /&gt;
    table-&amp;gt;horizontalHeader()-&amp;gt;setStretchLastSection(true);&lt;br /&gt;
    QGridLayout *layout = new QGridLayout;&lt;br /&gt;
    layout-&amp;gt;addWidget(table, 0, 0);&lt;br /&gt;
    setLayout(layout);&lt;br /&gt;
    setWindowTitle(tr(&amp;quot;Color Editor Factory&amp;quot;));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;QtGui&amp;gt;&lt;br /&gt;
#include &amp;quot;window.h&amp;quot;&lt;br /&gt;
int main(int argv, char **args)&lt;br /&gt;
{&lt;br /&gt;
    QApplication app(argv, args);&lt;br /&gt;
    Window window;&lt;br /&gt;
    window.show();&lt;br /&gt;
    return app.exec();&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>