Qt designer linux mint

Qt Documentation

Contents

Qt’s support for different Linux platforms is extensive and mature.

To download and install Qt for Linux, follow the instructions on the Getting Started with Qt page.

Supported Configurations

The following configurations are supported.

Distribution Architecture Compiler Notes
openSUSE 15.1 x86_64 GCC 5 or later, GCC 7, ICC 19.1
SUSE Linux Enterprise Server x86_64 GCC 5 or later, GCC 10
Red Hat Enterprise Linux 7.6 x86_64 GCC 5.3.1 via devtoolset-4
Ubuntu 18.04 x86_64 GCC 5 or later, GCC 9
Generic Linux x86 and x86_64 GCC (5 or later), ICC 18.x

Requirements for Development Host

The Qt installers for Linux assume that a C++ compiler, debugger, make, and other development tools are provided by the host operating system. In addition, building graphical Qt applications requires OpenGL libraries and headers installed. Most Linux distributions do not install all of these by default, but setting up a development environment is still straightforward.

Use the following commands to install the basic requirements for building Qt applications:

Debian/Ubuntu (apt-get)

Fedora/RHEL/CentOS (yum)

openSUSE (zypper)

Building Qt 5 from Source

You can also build Qt 5 from the source package and configure it according to your target platform. The source packages are obtained from http://www.qt.io/download/.

Below, you will find more information about building Qt from source.

Deployment and Other Issues

The pages below covers specific issues and recommendations for creating Linux/X11 applications.

Where to Go from Here

We invite you to explore the rest of Qt. We prepared overviews which help you decide which APIs to use and our examples demonstrate how to use our API.

  • Qt Overviews — list of topics about application development
  • Examples and Tutorials — code samples and tutorials
  • Qt Reference Pages — a listing of C++ and QML APIs
  • Qt X11 Extras — provides additional APIs for X11

Qt’s vibrant and active community site, http://qt.io houses a wiki, a forum, and additional learning guides and presentations.

В© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Источник

Создаём окружение для PyQt5 в Linux MInt (Ubuntu)


Давно уже до пятой версии обновился Qt и вместе с ним PyQt, но найти информацию по ним в русскоязычном сегменте — задача не из простых. Под катом подробный туториал для тех, кто только начинает знакомиться со связкой Qt + python3.

Цель: собрать и настроить окружение, пройти путь от установки PyQt5 и создания формы в Qt Designer до запуска переносимого бинарника под Windows (да, всё верно, разрабатываем под Mint, собираем для linux и windows).

Пути установки

/dev/
Мы будем использовать виртуальные окружения для питона, и хранить их будем в директории envs, т.е.

/dev/envs/
Наши проекты будут храниться в директории src, т.е.

/dev/src/

Если у вас уже сложилась собственная иерархия размещения файлов, то придётся скорректировать пути в командах, приведённых ниже.

Настройка окружения

Создаём структуру директорий. Откройте консоль и выполните:

Ставим пакет, который потребуется нам для сборки в будущем:

Ставим pip и virtualenv:

Создаём виртуальное окружение, активируем его и обновляем пакеты:

Ставим Qt5. При выборе пути установки я оставил «по-умолчанию»

/Qt. Если Вы выберите другой, то необходимо менять пути в командах ниже:

Ставим SIP — модуль, необходимый для работы PyQt:

На этом всё. Окружение установлено и готово к работе. Для проверки выполните команду:

Ответ должен выглядеть следующим образом:

Для проверки, что всё действительно установилось в виртуальное окружение, откройте новое окно терминала и повторите команду проверки:

В ответ должна появиться ошибка ImportError. Новое окно терминала после этого можно закрыть.

Создание приложения

Перейдём в директорию с нашими исходниками и создадим директорию проекта:

Далее нам потребуется Qt Designer. Если Вы не меняли пусть установки Qt, то запустить его можно командой:

Вот так выглядит запущенный Qt Designer на моей системе:

В данном руководстве я не буду подробно останавливаться на описании интерфейса дизайнера, мы пройдём простейший путь до минимальной готовой формы. Если Вам необходима более подробная информация — Google It!

В диалоговом окне выбираем «Widget» (последний пункт в списке «templates/forms») и нажимаем кнопку «Создать». Откроется форма редактирования виджета:

Перетащите на форму кнопку из меню слева и сохраните полученную форму с именем test.ui в директорию

/dev/src/pyqt_test/:

Tips&Tricks: Нажав [Crtl + R] Вы можете запустить свою форму и «потрогать» её в режиме реального времени.

Конвертируем файл интерфейса из XML формы в понятную python форму:

Я не хочу редактировать что-либо в файле, созданном конвертером PyQt, поэтому наши слоты мы опишем в отдельном файле. Создайте файл test_slots.py и откройте его в любимом Вами редакторе. Наполнение файла должно выглядеть примерно так:

Затем, создайте ещё один файл с именем main.py, в котором мы опишем основную логику:

На этом наше приложение завершено. Выполнив из консоли

мы должны увидеть форму с кнопкой посередине, нажатие на которую меняет название кнопки на системную дату.

Упаковка в исполняемый файл для Linux

Упаковщик потребует некоторой магии при установке.
Скачиваем пакет, не устанавливая его и распаковываем:

Открываем любимым редактором файл cx_Freeze-4.3.4/setup.py. Я использую SublimeText:

Правим строку №84, чтобы она выглядела, как на картинке:

Tips&Tricks: А вы знали, что если запустить SublimeText из виртуального окружения, то интерпретатором по-умолчанию будет из виртуального окружения?

Сохраняем изменения, закрываем редактор, устанавливаем пакет, возвращаемся в папку с исходниками, запускаем упаковку:

После этого в директории с исходниками появится директория dist, в которой среди множества файлов можно заметить файл без расширения main — это и есть наш бинарник, готовый для запуска и переноски. Откровенно говоря, немного расстраивает размер дистрибьютива: на моей машине это — 70,1 Мб, но не стоит забывать, что туда упакованы: python, PyQt, Qt и некоторые общесистемные библиотеки. Сборочный скрипт cxfreeze достаточно гибко конфигурируется, но подбор оптимальных параметров я оставлю на совести читателя. Скажу только, что счастье кроется в сжатии, оптимизации и ручном ограничении зависимостей.

Упаковка в исполняемый файл для Windows

К сожалению, чуда не будет. Мне не известен способ собрать exe напрямую из-под Linux-системы. Поэтому, придётся потанцевать с wine.
Закрываем открытый в самом начале терминал:

Открываем новый, ставим последнюю версию wine:

После этого скачиваем windows-версии уже знакомых нам пакетов и запускаем установку из-под wine:

А дальше немного магии. Идём по ссылке:

Качаем актуальную версию cx_Freeze для нашего интерпретатора и ставим поверх официальной:

После этого остаётся проверить работоспособность. Переходим в каталог с исходником, открываем терминал wine, выполняем уже знакомую команду сборки:

Оказалось, что у меня в распоряжении нет windows-машины, поэтому смог протестировать результат только под wine. Выходим из терминала wine (команда exit), закрываем терминал. Идём раздавать нашу программу всем желающим.

Источник

The Codeslinger

Programming, Computer, Technology, Media

Manual Install of Qt6 on Linux Mint

The next major version of Qt6 was released about two weeks ago, and I wondered how to get it to run on Linux. It is pretty simple on Windows because almost everything is based on an installer, and so the Qt installer fits in nicely. On Linux, however, where everything is package-manager based, how would you go about it there?

Let me show you how I did it.

Out of curiosity, I started by looking at what the apt package manager thinks about Qt6. For reference, I searched for «qt5» to get a baseline on how it should look.

Now, the same thing with «qt6».

As I expected, Qt6 is not yet part of the package repository. That means, to install it, you need to download the official Qt installer and do what every Windows user does 😅 Or you can grab the sources and compile it yourself, just out of spite.

So, go to «https://www.qt.io/download-open-source" and download the installer. I have linked to the Open Source variant, so be mindful of the requirements that come with it. But, since this is about Linux, I am sure you are aware of what that means.

Installation

Before you can start the installer, you must set the execute-bit. I ran it as a superuser because I wanted to install it to /opt . If you are happy with the applications and libraries to be located in your user directory, feel free to do so and omit sudo .

There are two unfortunate things you will notice when the installer comes up:

  1. It looks like a terrible «gamer software» with a green accent color instead of the more typical red. I hate that, and if anyone from the Qt Company ever stumbles across this blog post, please change it and use more of the native look and feel of the host OS. It is okay to have some corporate branding, like the buttons, for example, so they match the website’s look. But your website isn’t all green, now is it?
  2. You must create a Qt Account to install the framework. That is a bummer, and it has already driven me crazy in a previous version of the installer on Windows. Once the anger passes, create the account and be done with it. Or wait for the package manager to support it or maybe get the sources and compile yourself. I do not know if downloading the sources requires such an account, though.

The next two images show the location where I installed the Qt 6 stuff (the reason for sudo ) and what packages and tools I selected. You can go all-out and install everything there is, or start minimalistic like I did and add more features over time when you need them.

By default, Cmake and Ninja are selected. I deselected these options and installed the necessary tools myself using the apt package manager. If possible, I prefer that over a custom installer.

Continue through the wizard, and after downloading and unpacking a bunch of stuff, you are good to go. Now that you have installed Qt 6, there are a few more things to know and tweak to make the framework more convenient to use.

Panel Shortcut (*.desktop)

If you already have Qt Creator installed through the package manager, you can edit that file or copy it and use it as a basis for your own. I created a copy since I thought I do not want the package manager to update the file it created or remove it when I make changes to the Qt 5 installation.

The only things I changed are «Exec» and «Name».

Usage

If you run qmake from the command line, you either get an error or the version installed by your package manager. There are a few ways to work around this:

  1. export PATH=/opt/Qt/6.0.0/gcc_64/bin/:$PATH
  2. Modify the qtchooser configuration file: https://askubuntu.com/a/436539
  3. Create a symlink to the Qt 6 qmake binary, ln -s /opt/Qt/6.0.0/gcc_64/bin/qmake /usr/bin/qmake . I have one called /usr/bin/qmake6 . You can also name it /usr/bin/qmake , but I wanted to avoid potential issues with the package manger «fixing» this back to the Qt 5 version.

CMake

Qt 6 recommends using the CMake build tool in favor of Qt’s stalwart qmake utility. If you plan only to use Qt Creator then you are all set. It does all the necessary configuration for you. However, if you run CMake from the command line, you will likely encounter this error.

I remember it fondly from a little issue I ran into on Windows a short while ago. The fix is simple:

Источник

How to install Qt Designer onto Ubuntu Linux for Python

How to install Qt Designer onto Ubuntu Linux for Python

Note important update about QT Designer below!!
This is the easiest way using an Ubuntu Linux Virtual Machine with Virtual Box

Qt Creator has had support for python since version 2.8. The latest version is 3.3.

As you mention, with PyQt, licensing for commercial development ins’t free.

One alternative you don’t metnion is PyOtherside which is a Qt 5/QML plugin that allows you to (mostly) use Python for your backend code instead of Javascript. While Qt Creator does havea QML designer, you may find that the language is declarative enough that you prefer writing it by hand. I, for instance, use my qmlive tool when creating QML apps*, which allows me to do live coding. If you need something more native looking, QML does have Qt Quick Controls which provides native widgets for Windows, Linux, Mac, Android, and (I think) iOS). One final benefit of going the QML route is that in practice, it’s language independent. For instance, the little demo in the video started out with a javascript backend, then I ported it to Haskell, though I could have easily done the same with Python.

  • The tool currently doesn’t work with using QML Controls and I haven’t updated it since creating it since I primarily do web development at the moment.

All the tools you need are included in Ubuntu repositories. You must install the package qtcreator , which has an integrated QtDesigner, and the package pyqt5-dev-tools , which provides pyuic5 , a utility that generates Python code from .ui files.

To convert to Python use:

pyuic4 editorFrame.ui -o editorFrame.py

You may need to install utility so use:

apt-get install pyqt4-dev-tools

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don’t worry as I don’t post stupid cat videos or what I eat!

Источник

Читайте также:  Linux выбрать строку с номером
Оцените статью