qtgui

Menubar/ System tray app with Qt

谁说胖子不能爱 提交于 2019-12-03 05:06:13
I am new in Qt (PyQt) and I am trying to make an app whose functions will be executed from menubars/system trays. A perfect example is show here: I cannot find a good resource on how I can do this. Can someone advice. Thanks. I think you are looking for working with QMenu and QMainWindow for the menu part, at least. Here you can find a C++ example: Menus Example and here a PyQt4 example: Menus and Toolbars in PyQt4 Here is the code inline for your convenience: import sys from PyQt4 import QtGui class Example(QtGui.QMainWindow): def __init__(self): super(Example, self).__init__() self.initUI()

Qt slider widget with tick text labels

纵饮孤独 提交于 2019-12-03 02:54:19
I'm searching for Qt widget like QSlider, but with text tick labels support like this: This widget I'll use as mode switcher. Have you met something like that? I would use a QSlider with QLabel (s) attached as below. My usual disclaimer goes that you may need some fine-tuning and adjustment on your own for sure. main.cpp #include <QMainWindow> #include <QApplication> #include <QGridLayout> #include <QSlider> #include <QLabel> class MainWindow Q_DECL_FINAL : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = Q_NULLPTR) : QMainWindow(parent) { QSlider *slider = new

Qt: making a stacked barchart with different colors [closed]

回眸只為那壹抹淺笑 提交于 2019-12-02 08:54:44
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'm trying to make a timeline in Qt, where a different color stands for a different task. Ultimately, it should look a bit like this (but only one line); Now anyone got any ideas how to do this without installing extra libraries, but just with QPaint? The data it is representing is stored in a self-defined

Qt console application “WARNING: QApplication was not created in the main() thread”

好久不见. 提交于 2019-12-02 08:50:13
问题 I'm creating a very simple C++ QT console application from an example given here on stack overflow. How to use QFileSystemWatcher to monitor a folder for change The code is exactly as the code in that application and I'm developing with Qt's UI, Qt Creator with MinGW 32bit. I selected the console application from the projects I could choose as I have no need for a graphical user interface. Once the application has finished loading, the application shows the error message "WARNING:

Qt console application “WARNING: QApplication was not created in the main() thread”

帅比萌擦擦* 提交于 2019-12-02 06:05:08
I'm creating a very simple C++ QT console application from an example given here on stack overflow. How to use QFileSystemWatcher to monitor a folder for change The code is exactly as the code in that application and I'm developing with Qt's UI, Qt Creator with MinGW 32bit. I selected the console application from the projects I could choose as I have no need for a graphical user interface. Once the application has finished loading, the application shows the error message "WARNING: QApplication was not created in the main() thread" then does nothing. I have tried debugging the application but

QListWidget, insert linebreak for longer text

拥有回忆 提交于 2019-12-02 05:55:05
问题 I want to use QListWidget to display my content. But some of the content is quite long and I want to make the text continue on a second row instead of showing a horizontal scrollbar. I use Qt Creator and I can't seem to find any options in the design view. 回答1: Enable word wrapping by calling void setWordWrap ( bool on ) and set text elide mode to Qt::ElideNone void setTextElideMode ( Qt::TextElideMode mode ) Also you may check that you didn't set too small maximum height for your items in

Qt: making a stacked barchart with different colors [closed]

大憨熊 提交于 2019-12-02 05:18:29
I'm trying to make a timeline in Qt, where a different color stands for a different task. Ultimately, it should look a bit like this (but only one line); Now anyone got any ideas how to do this without installing extra libraries, but just with QPaint? The data it is representing is stored in a self-defined structure. Any help is welcome. Thx! You seem to need something like the code below, although please note that it is just pseudo code, and the exact details depend a lot on how you get the data from your datastructure which you have not yet shared with us. ... QPainter *painter = new

Qt : setData method in a QAbstractItemModel

蹲街弑〆低调 提交于 2019-12-01 17:47:52
问题 I'm new to model view and I have been following this tutorial while checking the documentation at the same time and I stumbled upon this little detail : The code of the tutorial which can be downloaded here has in the QAbstractItemModel class (here QAbstractListModel) the setData method which code is : def setData(self, index, value, role = QtCore.Qt.EditRole): if role == QtCore.Qt.EditRole: row = index.row() color = QtGui.QColor(value) if color.isValid(): self.__colors[row] = color self

Qt : setData method in a QAbstractItemModel

依然范特西╮ 提交于 2019-12-01 17:23:26
I'm new to model view and I have been following this tutorial while checking the documentation at the same time and I stumbled upon this little detail : The code of the tutorial which can be downloaded here has in the QAbstractItemModel class (here QAbstractListModel) the setData method which code is : def setData(self, index, value, role = QtCore.Qt.EditRole): if role == QtCore.Qt.EditRole: row = index.row() color = QtGui.QColor(value) if color.isValid(): self.__colors[row] = color self.dataChanged.emit(index, index) return True return False According to the explanations in the tutorial and

How can I allow user resize on elements within the window using Qt designer?

跟風遠走 提交于 2019-12-01 05:29:09
问题 I want to allow a user using my application to be able to drag a boundary between two widgets in my window which will resize the two (i.e. you drag it down and the top one will get bigger while the bottom gets smaller, and vice-versa). Is there anything in Qt designer that will allow a user to resize an element in the window, within certain constraints? Thank you 回答1: What you're describing is called a QSplitter widget. In Qt Designer, you can create one by selecting 2 or more widgets , and