How can I select the QGraphicView Item and change the properties
How can I select the
QGraphicView
items using mouse and change the properties(size,color).In this code I create Rectangles when the button clicks.But now I need to change properties of the rectangles.How can I select the each rectangle shapes using mouse and change the properties of the each one.
void Widget::on_btnCreateRect_clicked() { QBrush blueBrush(Qt::green); QPen blackPen(Qt::black); blackPen.setWidth(2); rect = ui->graphicsView->scene()->addRect(-10,-10,250,100,blackPen); rect->setFlag(QGraphicsItem::ItemIsMovable, true); }
http://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html
In this example it can select square shapes and change the color of each squares.I need to do same thing and change the size of each shape,but I have no idea to do it.how can I do it?
Рекомендуем хостинг TIMEWEB
Стабильный хостинг, на котором располагается социальная сеть EVILEG. Для проектов на Django рекомендуем VDS хостинг.Вам это нравится? Поделитесь в социальных сетях!
Комментарии
Только авторизованные пользователи могут публиковать комментарии.
Пожалуйста, авторизуйтесь или зарегистрируйтесь
Пожалуйста, авторизуйтесь или зарегистрируйтесь
B
- Bogdannn
- 28 марта 2024 г. 5:15
C++ - Тест 001. Первая программа и типы данных
- Результат:46баллов,
- Очки рейтинга-6
Последние комментарии
Qt Linux - Урок 001. Автозапуск Qt приложения под Linux как сделать автозапуск для флэтпака, который не даёт создавать файлы в ~/.config - вот это вопрос ))
АК
Qt WinAPI - Урок 007. Работаем с ICMP Ping в Qt Без строки #include <QRegularExpressionValidator> в заголовочном файле не работает валидатор.
Анатолий Кононенко5 февраля 2024 г. 12:50
EVA25 декабря 2023 г. 21:30
Boost - статическая линковка в CMake проекте под Windows Сделал всё по-как у вас, но выдаёт ошибку [build] LINK : fatal error LNK1104: не удается открыть файл "libboost_locale-vc142-mt-gd-x64-1_74.lib" Хоть убей, не могу понять в чём дел…
Qt/C++ - Урок 056. Подключение библиотеки Boost в Qt для компиляторов MinGW и MSVC Для решения твой проблемы добавь в файл .pro строчку "LIBS += -lws2_32" она решит проблему , лично мне помогло.
Сейчас обсуждают на форуме
Как получить в массив значения из связанной модели? Спасибо, разобрался:))
AC
QML Обнулить значения SpinBox Доброго времени суток, не могу разобраться с обнулением значение SpinBox находящего в делегате. import QtQuickimport QtQuick.ControlsWindow { width: 640 height: 480 visible: tr…
Alexandru Codreanu19 января 2024 г. 22:57
BlinCT27 декабря 2023 г. 19:57
Дмитрий10 января 2024 г. 15:18
Evgenii Legotckoi12 декабря 2023 г. 17:48
It is very big question.
First I give You idea, from that You can start, but some example I can write to you on weekend only.
Therefore, first, try to make changing of color.
For example, You need to make your own class from QGraphicsItem, or QGraphicsRectItem.
Example in this article . In this article You will find example of moving items on QGraphicsScene without flag ItemIsMovable. You need just to change logic to changing of color instead of moving the item.
Ok I'll check it sir,If you can please do article(tutorial) about this,Its really useful.Thank you
if you can give me some sample code when you free.thanks again
I found my old project, where I made simple Vector Editor. I wrote article about this editor and you will find link to project.
You can research it. In this project You will see, why I said your question is very big.
And It will be very cool, if have oportunities to share this article in some socials networks. Thanks.
Thank you very much sir,My next problem was how re - size the QGraphicViewItem (such as rectangle) using mouse,I think your project also have that function,thanks again :)
You are correct sir, this is a big question,most part of your solution I can't understand.If you can please explain your project sir.If you can please explain your code with each classes or please make some video tutorial with basic example,thank you
https://evileg.com/post/291/
I posted it here sir