Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.5k Topics 457.1k Posts
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    17 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • Adding the compilation of a non Qt application in the build chain.

    Unsolved
    2
    0 Votes
    2 Posts
    407 Views
    aha_1980A
    @Lolo67 Yes this should be possible - depending on how the app is compiled it should be more or less simple. Take a look at QtCreators wizards: You can select File > New File or Project > Non-Qt Project and have Plain C and Plain C++ Application there. This might be a good start.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    5 Views
    No one has replied
  • Completion problem with QLineEdit and QItemDelegate

    Solved
    2
    0 Votes
    2 Posts
    1k Views
    M
    Finally found a solution. I used a QTextEdit, it does not work with QLineEdit, I don't know why. I still have a small problem, I can't close the completion popup when I hit the return key, so I must hit return key, twice. Not a big problem. import sys from PyQt5.QtCore import QAbstractTableModel, Qt, QVariant, pyqtSignal from PyQt5.QtGui import QTextCursor, QTextOption from PyQt5.QtWidgets import (QAbstractItemDelegate, QApplication, QCompleter, QItemDelegate, QMainWindow, QTableView, QTextEdit) class MyLineEdit(QTextEdit): returnPressed = pyqtSignal() def __init__(self, parent=None): super().__init__(parent) self.setAcceptRichText(False) self.setWordWrapMode(QTextOption.NoWrap) self.setUndoRedoEnabled(False) self.setTabChangesFocus(True) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.completer = None self.textChanged.connect(self.textHasChanged) def setCompleter(self, completer): if completer: completer.setWidget(self) completer.setCompletionMode(QCompleter.PopupCompletion) completer.setCaseSensitivity(Qt.CaseInsensitive) completer.setModelSorting( QCompleter.CaseSensitivelySortedModel) completer.setMaxVisibleItems(15) completer.activated.connect(self.insertCompletion) self.completer = completer def insertCompletion(self, completion): print('>>> insertCompletion') if self.completer and self.completer.widget() == self: self.completer.widget().setPlainText(completion) self.completer.widget().moveCursor(QTextCursor.EndOfLine) self.completer.widget().ensureCursorVisible() def focusInEvent(self, event): print('>>> focusInEvent') if self.completer: self.completer.setWidget(self) super().focusInEvent(event) def keyPressEvent(self, event): print('>>> keyPressEvent') if self.completer and self.completer.popup().isVisible(): if event.key() in (Qt.Key_Return, Qt.Key_Enter, Qt.Key_Tab, Qt.Key_Backtab, Qt.Key_Escape): event.ignore() return else: if event.key() in(Qt.Key_Return, Qt.Key_Enter): self.returnPressed.emit() return super().keyPressEvent(event) if not self.toPlainText(): self.completer.popup().hide() return self.completer.setCompletionPrefix(self.toPlainText()) self.completer.popup().setCurrentIndex( self.completer.completionModel().index(0, 0)) self.completer.complete() def textHasChanged(self): # remove new lines and strip left blank characters self.blockSignals(True) cursor = self.textCursor() self.setPlainText(' '.join(self.toPlainText().splitlines()).lstrip()) self.setTextCursor(cursor) self.ensureCursorVisible() self.blockSignals(False) class MyDelegate(QItemDelegate): def __init__(self, parent): super().__init__(parent) def createEditor(self, parent, option, index): strings = ('tata', 'tada', 'tadam', 'tete', 'titi', 'toto', 'tutu') completer = QCompleter(strings) editor = MyLineEdit(parent) editor.setCompleter(completer) editor.returnPressed.connect(self.commitAndCloseEditor) return editor def commitAndCloseEditor(self): print('>>> commitAndCloseEditor') editor = self.sender() self.commitData.emit(editor) self.closeEditor.emit(editor) def setEditorData(self, editor, index): if editor: editor.setText(index.model().data[0]) editor.selectAll() def setModelData(self, editor, model, index): if editor: model.setData(index, editor.toPlainText(), Qt.EditRole) class Model(QAbstractTableModel): def __init__(self): super().__init__() self.data = ['hello'] def rowCount(self, parent=None): return 1 def columnCount(self, parent=None): return 1 def data(self, index, role): if not index.isValid(): return QVariant() if role in (Qt.DisplayRole, Qt.EditRole): return self.data[0] return QVariant() def setData(self, index, value, role): if role == Qt.EditRole: self.data[0] = value top_left = self.index(0, 0) bottom_right = self.index( self.rowCount() + 1, self.columnCount()) self.dataChanged.emit(top_left, bottom_right, [Qt.DisplayRole]) return True return False def flags(self, index): return Qt.ItemIsEditable | super().flags(index) class MainWindow(QMainWindow): def __init__(self): super().__init__() self.model = Model() self.table = QTableView() self.table.setModel(self.model) delegate = MyDelegate(self.table) self.table.setItemDelegateForColumn(0, delegate) def initUI(self): self.show() self.setCentralWidget(self.table) if __name__ == '__main__': app = QApplication(sys.argv) mw = MainWindow() mw.initUI() sys.exit(app.exec_())
  • is it possible to host nodejs app inside qt app ?

    Solved qt5 node.js webview webengine qt5 webserver
    3
    0 Votes
    3 Posts
    3k Views
    QjayQ
    hey , sorry for not being clear but what i meant by hosted was like node app is not hosted anywhere . So i added node code to my qt project and in main.cpp i create a Qprocess of node and then just provide localhost url to webengineview. this solves my purpose. So in short what i did was : copied node app code to my qt project. created a process of node running the node app via Qprocess. provided localhost url:port to webengineview and it shows the app.
  • How can I delete Qt, installed with qt-opensource-linux-x64-5.10.0.run?

    Solved
    3
    0 Votes
    3 Posts
    1k Views
    A
    @aha_1980 Thank you!
  • Need help with ScrollArea and drawing widgets

    Solved
    2
    0 Votes
    2 Posts
    418 Views
    D
    I was probably asking a bit much with my original post (out of ignorance). I thought I'd update... After a bunch of experimenting, I tried using QGraphicsView and QGraphicsScene, I'll be darned if that didn't product the effect I was after! I realize now that I could probably have reduced my example more and narrowed my focus on the exact problem I was trying to solve. I dynamically add "surfaces" to my main windows vertical layout. The surface contains the QGraphicsView and QGraphicsSceen. I add the shapes to the scene of each surface. It seems to work perfectly! I pushed the changes to the original github link if anyone is curious...
  • Qt4 source download version

    Unsolved
    8
    0 Votes
    8 Posts
    2k Views
    JKSHJ
    @Jim-Jensen said in Qt4 source download version: There seem to be conflicts with the definition of Bool in Xlib.h. Workaround is to replace "Bool" with "int" in Xlib.h What is the exact error message for the conflict? C++ has had the standard bool type from day 1, so I'd be very surprised if the conflict is with Qt code. See https://www.x.org/releases/X11R7.6/doc/libX11/specs/libX11/libX11.html -- Xlib requires a specific order for including headers. Perhaps this might be related to your issue? I want to stick with software (including Qt versions) provided in current popular distros. You'll be relieved to hear that Qt promises source- and binary-compatibility within major versions, so software written for Qt 4.7 should compile and run just fine with Qt 4.8, for example. (However, there are breaking changes between Qt 4.x and Qt 5.x)
  • in qt3d if my file is larger than 2G ,upto 4G,how to handle this?

    Unsolved
    9
    0 Votes
    9 Posts
    2k Views
    J
    sorry for reply late, the object i mean it is the 3DObject for render in the Qt3DWindow .. if my 3D format file such as STL file is large than 2G maybe will exceed 4G ,how to render this file into Qt3DWindow
  • Synchronous QT HTTP GET for Json parsing

    Unsolved
    8
    0 Votes
    8 Posts
    2k Views
    SGaistS
    With a lambda you can keep everything pretty tidy.
  • Embed a QWizard inside QTabWidget

    Solved
    9
    0 Votes
    9 Posts
    2k Views
    J
    @ambershark Thank you for your reply, it clarifies a lot things. I will be more careful with the proper setup of parent.
  • Why does escaping backslash returns double backslash?

    Unsolved
    2
    0 Votes
    2 Posts
    837 Views
    SGaistS
    Hi, Wouldn't QChar simplify things in this case ?
  • This topic is deleted!

    Unsolved
    4
    0 Votes
    4 Posts
    88 Views
  • binding to reference of type discards qualifiers

    Unsolved
    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • opencv convert numpy array to image

    Unsolved
    2
    0 Votes
    2 Posts
    633 Views
    SGaistS
    Hi, In what way is this related to Qt ? From the looks of your question, you should rater ask on the OpenCV or Numpy forums.
  • qt setup,infinite recursion?

    Unsolved
    6
    0 Votes
    6 Posts
    1k Views
    SGaistS
    Hi, uic is run.
  • Where is ui_mainwindow.h in Qt designer

    Unsolved
    5
    0 Votes
    5 Posts
    6k Views
    aha_1980A
    @adamchalkley2018 said in Where is ui_mainwindow.h in Qt designer: ohh ok so behind the scenes QT is creating this header and UI object for us? The .ui file is generated by a wizard (it's a template) and can be edited later with QtDesigner (also integrated in QtCreator). From the .ui file a ui_object.h file is generated by uic and later compiled by the C++ compiler and linked to your executable. Hope that explains it a bit :)
  • 0 Votes
    2 Posts
    2k Views
    enjoysmathE
    Fixed it. You have to make sure that the QTreeWidgetItem is actually in the tree first before calling setItemWidget on the tree.
  • Console app close issue

    Solved
    6
    0 Votes
    6 Posts
    2k Views
    aha_1980A
    @Cobra91151 said in Console app close issue: pingProcess.startDetached("ping.exe", QStringList() << "8.8.8.8" << "-t"); I think your problem is the "-t" parameter. What happens if you replace that with "-n" << "4" ? Because with "-t" ping never stops, while with "-n 4" it only pings four times. Disclaimer: I cannot test as I don't have Windows at hand... Edit: Ah, I see you got it. So please close this thread as SOLVED. Thanks