Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.7k Posts
  • QPdfView, QSerial port, Gstreamer issues

    Unsolved
    8
    0 Votes
    8 Posts
    792 Views
    C
    @ddddddxxx said in QPdfView, QSerial port, Gstreamer issues: turns out that if you close port before that function finishes no data will be sent. However I don't know why is that. If all that code was inside a slot then the QSerialPort object is destroyed at the end of the slot execution (current scope of object). QSerialPort, or any of the QIODevice sub-classes, will not actually send or receive data until your code enters the Qt event loop. This happens when the slot exits but by that time your object is no more.
  • This topic is deleted!

    Unsolved
    7
    0 Votes
    7 Posts
    402 Views
  • [Re] Qlistwidget move up and down?

    Unsolved
    4
    0 Votes
    4 Posts
    608 Views
    SGaistS
    Here a small example showing the painting of a button in the delegate. You can adapt it to your needs (i.e. draw two buttons instead one and detect which button should be down when pressed) import sys from PySide6.QtCore import QAbstractItemModel from PySide6.QtCore import QEvent from PySide6.QtCore import QModelIndex from PySide6.QtCore import Signal from PySide6.QtGui import QMouseEvent from PySide6.QtGui import QStandardItem from PySide6.QtGui import QStandardItemModel from PySide6.QtWidgets import QApplication from PySide6.QtWidgets import QStyle from PySide6.QtWidgets import QStyledItemDelegate from PySide6.QtWidgets import QStyleOptionButton from PySide6.QtWidgets import QStyleOptionViewItem from PySide6.QtWidgets import QTableView class Delegate(QStyledItemDelegate): clicked = Signal(QModelIndex) def __init__(self, parent=None) -> None: super().__init__(parent) self._is_down = False def _build_option(self, option, index: QModelIndex) -> QStyleOptionButton: pb_style = QStyleOptionButton() pb_style.state = option.state pb_style.state |= QStyle.State_Sunken if self._is_down else QStyle.State_Raised pb_style.fontMetrics = option.fontMetrics pb_style.rect = option.rect pb_style.text = index.data() return pb_style def editorEvent( self, event: QEvent, model: QAbstractItemModel, option: QStyleOptionViewItem, index: QModelIndex, ) -> bool: if isinstance(event, QMouseEvent): if event.type() == QEvent.MouseButtonPress: self._is_down = True elif event.type() == QEvent.MouseButtonRelease: self._is_down = False self.clicked.emit(index) return True return False def paint(self, painter, option, index) -> None: button_option = self._build_option(option, index) qApp.style().drawControl( QStyle.CE_PushButton, button_option, painter, self.parent() ) def show_text(index: QModelIndex) -> None: print(index.data()) if __name__ == "__main__": app = QApplication(sys.argv) view = QTableView() model = QStandardItemModel(3, 2) for row in range(model.rowCount()): for column in range(model.columnCount()): item = QStandardItem(f"row {row}, column {column}") model.setItem(row, column, item) view.setModel(model) delegate = Delegate(view) view.setItemDelegateForColumn(1, delegate) view.show() delegate.clicked.connect(show_text) sys.exit(app.exec())
  • error "float.h" file not found

    Unsolved
    8
    0 Votes
    8 Posts
    4k Views
    F
    So please tell me how you solved this problem
  • Qt equivalent of JavaScript .charCodeAt()

    Solved
    2
    0 Votes
    2 Posts
    182 Views
    8Observer88
    Solution: QString str = "你好"; int code = str[0].unicode(); QHBoxLayout *hbox = new QHBoxLayout(this); QLabel *lbl = new QLabel(QString::number(code)); hbox->addWidget(lbl); setLayout(hbox);
  • When using QGridLayout in Qt Designer, it often fails to achieve the desired effect.

    Solved
    4
    0 Votes
    4 Posts
    371 Views
    S
    @John-Van Can't help you more without the specifics but I have some general tips that might help Stick to the default layout and sizing policies as much as possible. Whenever you start changing size policies etc. things typically go wrong. Basically never use fixed positioning or sizing Test your UI with multiple style engines. So many times I've seen that the layout is all messed up when you use for example KvAntum or another styling engine. Keep in mind many UI widgets can do clever things. For example QComboBox causes issues if the items contain long strings. You can try with minimum size to (but see what I said about using fixed sizes) Keep in mind the more you try the more you fail typically, i.e all together the more sizing policies, etc "clever things" you throw at it the more broken your layouts will get. So best is just accept that if it's wonky with defaults then that's what it is.
  • This topic is deleted!

    Moved Unsolved
    2
    0 Votes
    2 Posts
    23 Views
  • QDialog exec no longer modal after show

    Unsolved
    12
    0 Votes
    12 Posts
    994 Views
    SGaistS
    As explained in the method documentation, exec has some caveats to take into account when you design your application.
  • Qt Creator closes with terminal

    Unsolved
    8
    0 Votes
    8 Posts
    675 Views
    C
    @JacobNovitsky said in Qt Creator closes with terminal: I need to open Qt App with other Qt App It seems from the questions that you want to open an instance of Qt Creator, to open a Qt project B, from an application built by Qt project A (let's call it app A), running inside another instance of Qt Creator. Note that this is not the same as running the application built by Qt project B (let's call that app B). This appears to be be an unusual request leaving responders confused as to your intention. I think you might be confusing Qt Creator with the applications app A and app B. Are you sure you do not simply want Qt app A to launch app B? Note that there is no part to play for Qt Creator here. The source code of app A simply uses QProcess to give app A the ability to launch the binary of app B at run time.
  • App permissions in Ventura macOS

    Unsolved
    2
    0 Votes
    2 Posts
    158 Views
    SGaistS
    Hi, Which libraries were concerned ? What do you mean by permissions ?
  • Bundled App wont start, Run in QT Creator works

    Unsolved
    2
    0 Votes
    2 Posts
    174 Views
    SGaistS
    Hi, You can call qmake and make from them command line. Are you using any third party library ? Did you sign your application ? Did you try to start it from the command line to see if there was something reported ?
  • Qtimer not working

    Unsolved
    9
    0 Votes
    9 Posts
    769 Views
    SGaistS
    Hi, As @jsulm wrote, without more code it's not possible to understand what is going on. You might be doing stuff in the slots that could explain the issue.
  • How to forbid to use gnome terminal for specific app

    Unsolved
    5
    0 Votes
    5 Posts
    371 Views
    Pl45m4P
    @JacobNovitsky said in How to forbid to use gnome terminal for specific app: I need to debug it with QWindow something Then do so. Implement something where you can see debug messages in a QWidget. But it could be hard to track down issues when the GUI hangs/crashes and your "debug widget" is not responding either... There's a reason why debug output is send to a separate terminal/console and usually not displayed by the app you want to debug.
  • Compiling Qt6.5 for Raspberry Pi Zero for cross compiling

    Unsolved
    2
    0 Votes
    2 Posts
    343 Views
    S
    Update: I can compile 5.15.2 in the same way and the ABI is correct (arm-linux-generic-elf-32bit). So the question is: can qt 6.5.0 be compiled for ARMv6 32 bit? Or maybe any addition things should be done?
  • c++ does reads QList<QString> always empty when sent from QML

    Solved
    10
    0 Votes
    10 Posts
    558 Views
    S
    so at the end I converted that object array to JSON in QML, send it to C++, and in CPP recreated to JSON... bad practice but lets say ifs short code working, probably fast too
  • Qt Creator and Makefile based project. How?

    Solved
    2
    0 Votes
    2 Posts
    207 Views
    cristian-adamC
    Sure, see https://doc.qt.io/qtcreator/creator-projects-autotools.html for more information. It's about enabling the AutotoolsProjectManager plugin. I'm not sure if this works if you have your own baked makefile.
  • QButtonGroup at least one button must be checked.

    Unsolved
    5
    0 Votes
    5 Posts
    858 Views
    JoeCFDJ
    @jsulm I would define a std::bitset to do it for all checkboxes. If its value is 0, check the default one,
  • 0 Votes
    4 Posts
    915 Views
    cristian-adamC
    And if you just want to download the Qt OSS without an account you can use this CMake script via cmake -P download_qt6.cmake. It downloads Qt 6.4.2. No idea if it would work with Qt 6.5. But you don't get the ability to upgrade things like you can do with the official installer, and you'll have to manually do things.
  • get text from QTextEdit

    Unsolved
    4
    0 Votes
    4 Posts
    7k Views
    jsulmJ
    @JacobNovitsky What syntax? toPlainText() is a methof of QTextEdit class which you can call like any other method. QString text = ui->textEdit->toPlainText();
  • Could not load the Qt platform plugin "xcb" in "" even though it was found

    Unsolved
    2
    0 Votes
    2 Posts
    256 Views
    sierdzioS
    @JacobNovitsky Use qtcreator.sh, from the same directory.