Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.5k Topics 457.3k Posts
  • Qt 3D Qt3DExtras::Qt3DWindow::show() is slow.

    Unsolved qt3d qt3d scene3d
    1
    0 Votes
    1 Posts
    546 Views
    No one has replied
  • [Q3D] Setting aspect ration has no effect on an image

    Solved
    5
    0 Votes
    5 Posts
    366 Views
    V
    I jus try to anderstand the logic behide the way the pojection matrix is being formed in Qt3D. It's really poor documented and the code surfing is time consuming. For the moment I've solve my issue. Not quite elegantly but yet.... What I was trying to do back then is assigning the projection matrix myself to fit the properties of my camera. Eventually I did it but it has taken my dayoff to dig the code. When it comes to Framegraph it even worse.... Anyway anything NOT out of box is an automatic sentence to mining the code up to the end of your life your project life. It starts getting on my nerves. Only QML examples gives some explanation to the way things has to be done. Yet the QL and C++ versions are far from being isomorphic since QML is basically a configurator for C++ classes with thousands of wrappers to make it work. I've made the code above worked bt the problem is I don't know how yet. So the essue can be marked solve unfortunatly without a benifit to anyone
  • hasFocus() ??

    Unsolved
    6
    0 Votes
    6 Posts
    866 Views
    mrjjM
    Hi Useing code to check for fucus will work poorly if used in constructor and code must be run every time focus shifts so it's easier to do with stylesheet alone. QLineEdit:focus { color:red; } [image: drop4.gif]
  • QFileDialog::getOpenFileName with file name line edit?

    Solved
    2
    0 Votes
    2 Posts
    389 Views
    Christian EhrlicherC
    @Joachim-W said in QFileDialog::getOpenFileName with file name line edit?: at least not in native mode under Debian So why do you ask here when you use debian with a native gtk file dialog?
  • Btchat example doesn’t work correctly on Ubuntu 20.04

    Unsolved
    1
    0 Votes
    1 Posts
    451 Views
    No one has replied
  • how to use JSON from QJsonValue ?

    Solved
    6
    0 Votes
    6 Posts
    2k Views
    Xena_oX
    @JonB thank you @Alvein thank you , your example is great, i could figure out how to read the data response. so far its like guessing whats inside the data packet. thanks a lot :-)
  • 0 Votes
    3 Posts
    722 Views
    V
    hi there, JulianM Could you explain a little bitmore, how the vertex count affect the picking? and what was the problem exactly(how it was solved)?
  • How to change the border color of each cell without changing background color!

    Unsolved
    2
    0 Votes
    2 Posts
    182 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    15 Views
    No one has replied
  • Add an always visible spinbox colum in QtableView

    Unsolved
    2
    0 Votes
    2 Posts
    603 Views
    N
    I finally achieved to a good little result: [image: eaID3P9.png] I have some questions remaining: For the moment, the editor shows when double clicking anywhere on the column 2. I would like to show the editor only if the user clicked on the number on the center, and not on the arrows on the side. For that, I would need to retrieve the mouse position when entering the function createEditor, but I don't know how to do. I guess that I can re-implement in some way the function that makes the editor popping... Also, is my code ugly in term of conception ? What can I improve to make it prettier then ? from PySide2 import QtCore, QtWidgets, QtGui from model_ui.segment_model import Columns class SpinBoxDelegate(QtWidgets.QStyledItemDelegate): """This delegates allow a custom display of a spinbox into a tableview""" def __init__(self, parent): super().__init__(parent) def is_segment_analyzed(self, index): """Checks from a given SegmentModel index, if the corresponding segment have been analyzed """ analyzed_index = index.siblingAtColumn(Columns.analyzing.value) return not index.model().get_attribute_from_index(analyzed_index) def createEditor(self, parent, option, index): """Returns a new SpinBox widget if the segment have been analyzed""" if self.is_segment_analyzed(index): return QtWidgets.QSpinBox(parent) return None def setEditorData(self, editor, index): """Handles the way editor store new data""" editor.setValue(int(index.data())) def editorEvent(self, event, model, option, index): """This function is used to handle the interactions with handmade buttons. """ # If the event is a click event if event.type() == QtCore.QEvent.MouseButtonRelease: # Retrieves the button positions left_arrow_button, right_arrow_button = self.get_left_right_arrow_buttons(option) # Retrieves the combo index value from the model index current_combo_value = int(index.data()) value_changed = False # If left button was clicked, we decrease combo index if left_arrow_button.contains(event.pos()): if current_combo_value > 0: value_changed = True current_combo_value = current_combo_value - 1 # If left button was clicked, we increase combo index if right_arrow_button.contains(event.pos()): # TODO: Globally handle right combo limit (for all the project) value_changed = True current_combo_value = current_combo_value + 1 # Report the changes to the model if value_changed: model.setData(index, current_combo_value) def updateEditorGeometry(self, editor, option, index): editor.setGeometry(option.rect) def get_left_arrow_button(self, option): """Creates the left arrow button, depending on the option rect area""" arrow_buttons_size = option.rect.height()//1.5 left_arrow_box = QtCore.QRect( option.rect.left()+1, option.rect.top()+(option.rect.height()//4.5), arrow_buttons_size, arrow_buttons_size) return left_arrow_box def paint_left_arrow_button(self, painter, option): """Creates the left arrow button et paints it""" left_arrow_box = self.get_left_arrow_button(option) painter.drawRect(left_arrow_box) painter.fillRect(left_arrow_box, QtGui.QColor(255, 255, 255)) painter.drawText(left_arrow_box, QtCore.Qt.AlignCenter, "<") def get_right_arrow_button(self, option): """Creates the right arrow button, depending on the option rect area""" arrow_buttons_size = option.rect.height()//1.5 right_arrow_box = QtCore.QRect( option.rect.right()-arrow_buttons_size, option.rect.top()+(option.rect.height()//4.5), arrow_buttons_size, arrow_buttons_size) return right_arrow_box def paint_right_arrow_button(self, painter, option): """Creates the right arrow button et paints it""" right_arrow_box = self.get_right_arrow_button(option) painter.drawRect(right_arrow_box) painter.fillRect(right_arrow_box, QtGui.QColor(255, 255, 255)) painter.drawText(right_arrow_box, QtCore.Qt.AlignCenter, ">") def get_left_right_arrow_buttons(self, option): return self.get_left_arrow_button(option), self.get_right_arrow_button(option) def paint_left_right_arrow_buttons(self, painter, option): self.paint_left_arrow_button(painter, option) self.paint_right_arrow_button(painter, option) def paint(self, painter, option, index): painter.save() if not self.is_segment_analyzed(index): painter.setPen(QtGui.QPen(QtGui.QColor(255, 255, 255))) painter.drawRect(option.rect) painter.restore() return option_spinbox = QtWidgets.QStyleOptionSpinBox() option_spinbox.rect = option.rect option_spinbox.state = option.state # By default: white pen (eraser) painter.setPen(QtGui.QPen(QtGui.QColor(255, 255, 255))) # If the segment have been analyzed: we draw information # Else, we proint a blank cell if self.is_segment_analyzed(index): painter.setPen(QtGui.QPen(QtGui.QColor(0, 0, 0))) painter.drawText(option_spinbox.rect, QtCore.Qt.AlignCenter, str(index.data())) self.paint_left_right_arrow_buttons(painter, option_spinbox) painter.setPen(QtGui.QPen(QtGui.QColor(255, 255, 255))) # If the segment associated to the spinbox is selected: green line if option_spinbox.state & QtWidgets.QStyle.State_Selected: painter.setPen(QtGui.QPen(QtGui.QColor(0, 255, 0))) # Drawing boundaries painter.drawRect(option_spinbox.rect) painter.restore() def sizeHint(self, option, index): """Gives an hint about the minimal size of the element to the view""" number_of_digits_to_draw = len(str(index.data())) arrow_button_width = 25 width = number_of_digits_to_draw * 10 + 2 * arrow_button_width height = 45 return QtCore.QSize(width, height)
  • What is happening with forum post entry screen?

    Unsolved
    12
    0 Votes
    12 Posts
    878 Views
    Chris KawaC
    I do object to the sermons. It is getting tiresome. Likewise, lecturing others like that is no fun. I would rather not :/ You can all object to my style , but it is no business of yours. It is, as your style directly impacts us and others. You are not living in vacuum.
  • This topic is deleted!

    Moved Unsolved
    1
    0 Votes
    1 Posts
    19 Views
    No one has replied
  • Performance between Qt widget application and QML application

    Unsolved
    2
    0 Votes
    2 Posts
    138 Views
    SGaistS
    Hi, I am not aware of such benchmarks. You have to define exactly what you want to achieve and then do some tests.
  • Couple of strange errors. MSVS2019 + CMake + Qt

    Solved qt 6 msvc2019 cmake errors
    2
    0 Votes
    2 Posts
    626 Views
    DrugsAsLifestyleD
    Fixed. This errors was because of Qt 6. I downloaded and linked previous version of QT - 5.15, and this errors disappeared
  • How to enter Logical expression in QLineEdit with QCompleter?

    Solved qt5
    4
    0 Votes
    4 Posts
    415 Views
    S
    solved the problem by adding self.end_index = len(self.existing_txt) in pathFromIndex after getting the text value from QLineEdit
  • 0 Votes
    15 Posts
    5k Views
    JonBJ
    @n-2204 Please try to format your posts readably. For lines of code use the Code tag when posting, or but lines of 3-backticks above & below. You are also now asking this same question in a new thread you have created (https://forum.qt.io/topic/125774/qtableview-how-to-make-noneditable-column). You should stick to one thread, not create multiple ones. where i should give like it will be applicable for table1 or table2 I don't know what you mean. To use the flags() approach you must sub-class QStandardItemModel, which I assume is what your GAS_tool is, else this will have no effect. If you want to use the setFlags() approach, you do not need to sub-class, but must set the flags explicitly on each item which is to be non-editable. I also wrote this in your other thread.
  • warning QToolbar::actionTriggered is not a signal[crazy-connect-no-signal]

    Unsolved
    3
    0 Votes
    3 Posts
    278 Views
    E
    @mrjj Maybe it‘s a bug for the Qt 6.0
  • Proper way to make a cmake project (pri) dependent on another cmake project (pri)

    Solved
    2
    0 Votes
    2 Posts
    169 Views
    fcarneyF
    My paths were relative to a cd. This messed things up.
  • 0 Votes
    12 Posts
    12k Views
    N
    @sayan275 Not clear why, but I think this does what you need: set the keyboardTracking property of the spinbox to false, then do the following: void MainWindow::on_mySpinBox_valueChanged(int arg1) { on_mySpinBox_editingFinished(); } void MainWindow::on_mySpinBox_editingFinished() { // what you need to be done, on spinbox loosing focus or arrows adjusting (and not while editing) }
  • 0 Votes
    10 Posts
    774 Views
    jeremy_kJ
    @Inhahe said in How can I do something when the user clicks on a particular span/frame/block/fragment/whatever of text in a QTextEdit?: here's my code: def addmsg(textedit, nick, message): if config.show_timestamp: obj_now = datetime.now() textedit.insertPlainText(f"[{obj_now.hour: >2}:{obj_now.minute: >2}] ") textedit.insertPlainText("<") #textedit.insertHtml(f'<a href="{nick}">{nick}</a>') #doesn't work right, bug in qt charFormat = QTextCharFormat() charFormat.setAnchorHref(nick) textedit.textCursor().insertText(nick, charFormat) textedit.insertPlainText("> ") colorify(textedit, message) textedit.insertHtml("<br>") both the QTextCharFormat approach and the insertHtml approach (commented out in the above) result in the link extending all the way to the end of the line, which it seems it shouldn't. Just posting it in case you happen to have any insight; I expect I'll have to figure this out myself ;/ Using textedit.insertHtml(f'<a href="{nick}">{nick}</a>&gt;') rather than adding > as plain text fixes the issue for me with Qt 5.15.2 and PyQt 5.15.3. I haven't tried using the QTextCharFormat method.