Skip to content
QtWS25 Call for Papers
  • 0 Votes
    3 Posts
    765 Views
    jiapei1000J

    @Christian-Ehrlicher

    Yeah, I'm trying to build Qt-6.6.1 from console.
    It looks there are some 3rdparty libraries that have Python interfaces to be built. Particularly:

    qtwebengine-chromium qtwebengine [46/24233] ACTION //third_party/catapult/tracing:generate_about_tracing(/opt/qt/qtwebengine/build/src/core/target_toolchain:target) FAILED: gen/content/browser/tracing/about_tracing.js gen/content/browser/tracing/about_tracing.html /home/lvision/.pyenv/shims/python3 ../../../../../src/3rdparty/chromium/third_party/catapult/tracing/bin/generate_about_tracing_contents --outdir gen/content/browser/tracing Traceback (most recent call last): File "/opt/qt/qtwebengine/src/3rdparty/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/html_module.py", line 28, in Parse parser_results = parse_html_deps.HTMLModuleParser().Parse(self.contents) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/qt/qtwebengine/src/3rdparty/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/parse_html_deps.py", line 298, in Parse return HTMLModuleParserResults(html) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/qt/qtwebengine/src/3rdparty/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/parse_html_deps.py", line 164, in __init__ self._soup = bs4.BeautifulSoup(html, 'html5lib') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/qt/qtwebengine/src/3rdparty/chromium/third_party/catapult/third_party/beautifulsoup4-4.9.3/py3k/bs4/__init__.py", line 243, in __init__ raise FeatureNotFound( bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library? During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/qt/qtwebengine/build/src/core/Release/x86_64/../../../../../src/3rdparty/chromium/third_party/catapult/tracing/bin/generate_about_tracing_contents", line 14, in <module> sys.exit(generate_about_tracing_contents.Main(sys.argv[1:])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/qt/qtwebengine/src/3rdparty/chromium/third_party/catapult/tracing/tracing_build/generate_about_tracing_contents.py", line 32, in Main load_sequence = vulcanizer.CalcLoadSequenceForModuleNames(names) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/qt/qtwebengine/src/3rdparty/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/project.py", line 146, in CalcLoadSequenceForModuleNames modules = [self.loader.LoadModule(module_name=name, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/qt/qtwebengine/src/3rdparty/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/resource_loader.py", line 145, in LoadModule m.Parse(excluded_scripts) File "/opt/qt/qtwebengine/src/3rdparty/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/html_module.py", line 30, in Parse raise Exception('While parsing %s: %s' % (self.name, str(ex))) Exception: While parsing tracing.ui.extras.about_tracing.about_tracing: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library? [95/24233] CXX obj/third_party/cld_3/src/src/cld_3/nnet_language_identifier.o ninja: build stopped: subcommand failed. make[2]: *** [src/core/CMakeFiles/QtWebEngineCore_Release_x86_64.dir/build.make:77: src/core/Release/x86_64/QtWebEngineCore.stamp] Error 1 make[2]: Leaving directory '/opt/qt/qtwebengine/build' make[1]: *** [CMakeFiles/Makefile2:1472: src/core/CMakeFiles/QtWebEngineCore_Release_x86_64.dir/all] Error 2 make[1]: Leaving directory '/opt/qt/qtwebengine/build' make: *** [Makefile:149: all] Error 2
  • 0 Votes
    3 Posts
    734 Views
    L

    @jeremy_k

    Thank You for the explanation!

    As you said I had to implement the roleNames() Function and adjusted the data().

    The code below now works

    import sys import typing import PySide6 from PySide6 import QtCore from PySide6 import QtGui from PySide6.QtCore import QByteArray class ProductListModel (QtCore.QAbstractListModel): def __init__(self, products, parent = None): super().__init__(parent) self.products = products def data(self, index, role): """Returns an appropriate value for the requested data. If the view requests an invalid index, an invalid variant is returned. Any valid index that corresponds to a string in the list causes that string to be returned.""" row = index.row() if not index.isValid() or row >= len(self.products): return None product = self.products[row] if role == QtCore.Qt.DisplayRole: return product.name elif role == QtCore.Qt.EditRole: return product.name elif role == QtCore.Qt.UserRole + 1: return product.id elif role == QtCore.Qt.UserRole + 2: return product.name return None def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole): """Returns the appropriate header string depending on the orientation of the header and the section. If anything other than the display role is requested, we return an invalid variant.""" if role != QtCore.Qt.DisplayRole: return None if orientation == QtCore.Qt.Horizontal: return f"Column {section}" return f"Row {section}" def rowCount(self, parent: typing.Union[PySide6.QtCore.QModelIndex, PySide6.QtCore.QPersistentModelIndex] = ...) -> int: # return length of productList return len(self.products) def roleNames(self): roles = { QtCore.Qt.UserRole + 1: b'id', QtCore.Qt.UserRole + 2: b'name', } return roles class Product: def __init__(self, id:int, name:str): self.id = id self.name = name```
  • 0 Votes
    10 Posts
    3k Views
    SGaistS

    @tilz0R in addition to @JonB, don't call self.show in an __init__ method. It's not the role of the widgets to make themselves visible. That is the role of the object or method creating them.

  • Download full web page

    Solved QtWebEngine
    7
    0 Votes
    7 Posts
    685 Views
    Black CatB

    @mpergand Thank you man =)

  • 0 Votes
    2 Posts
    317 Views
    JoeCFDJ

    use splash widget?
    https://doc.qt.io/qt-6/qsplashscreen.html

  • 0 Votes
    1 Posts
    766 Views
    No one has replied
  • 0 Votes
    2 Posts
    237 Views
    SGaistS

    Hi,

    That's because these classes are no widgets, there are used to build the UI.

    In you code snippet, you would use self.nextui.hide() to hide the widget that was created with the help of Registration.Ui_Registration. That is the same for all the widgets you created that way.

  • 0 Votes
    3 Posts
    313 Views
    L

    thank you sir for your help

  • 0 Votes
    4 Posts
    251 Views
    VRoninV

    Yes, Qt.EditRole and Qt.DisplayRole are the same thing in non-customised Qt classes

  • 0 Votes
    4 Posts
    364 Views
    JonBJ

    @lanas
    Yes to all of that, by all means read that overview link. I didn't say that "will be hard to retrive data from data base if i did not work with qtsql classes". Using the Python SQL classes instead would be fine for retrieving data from the database. But when you want to display that data in your Qt UI, rows & columns from your SQL queries, that will require some coding to get the Python-SQL-fetched-data to the Qt UI widgets and back. Whereas if you use the Qt classes they fill Qt models directly, and those are what Qt QTableViews use to display (and even edit) data.

    In the simplest case, see if you can't use Qt's QSqlTableModel for attaching your data retrieval to the database. That will have the necessary SELECT/INSERT/UPDATE/DELETE automatically generated/issued for you for working on a SQL table in the database, without you having to write the SQL statements like you tried to in your question. And attaching a QTableView to the QSqlTableModel will display what you fetched without any code. And it can even allow you/the user to edit the data in the table and write ot back to the database for you.

  • 0 Votes
    6 Posts
    2k Views
    SGaistS

    Depending on your end goal, you might want to consider using a library like OpenCV to do the zooming part and Qt to display the result.

  • 0 Votes
    12 Posts
    2k Views
    JonBJ

    @CEO said in How to display QTableWidget selected row in a qLineEdit of the same class?:

    @JonB now I discovered you are either hoarding knowledge or might not have done any work on the question.

    Yes, you're right. I have nothing better to do than lie to questioners about what I know and they should do, and I don't spend enough of my time writing the code demanded to save them time.

    Here is an extract from my usage of the QDataWidgetMapper which I know nothing about from a sample project of mine. I'm sorry if my variables/widgets/model are not the same as yours. Also here I happen to be binding to QSpinBoxes, let me know if I need to change it to QLineEdits for you.

    void SectorRegisters::initDataWidgetMapper() { // set up the `QDataWidgetMapper` this->dwm = new QDataWidgetMapper(this); // set model (this->sectorsModel is the model being used, in my case it's a `QStandardItemModel`) SectorsModel *sectorsModel = this->sectorsModel; dwm->setModel(sectorsModel); // Vertical => widget mapped to row dwm->setOrientation(Qt::Vertical); // current index is always column #0 dwm->setCurrentIndex(0); // Region mappings dwm->addMapping(ui->spinRegionSocialState, SectorsModel::RegionSocialState); dwm->addMapping(ui->spinRegionGoodAreas, SectorsModel::RegionGoodAreas); dwm->addMapping(ui->spinRegionPoorAreas, SectorsModel::RegionPoorAreas); dwm->addMapping(ui->spinRegionCash, SectorsModel::RegionCash); // Here there are many further widget<->model-column mappings // ... }

    You're welcome.

  • 0 Votes
    3 Posts
    2k Views
    JonBJ

    @Lalremruata said in How to avoid Null or empty value in QLineedit of Pyqt5:

    even the self.lineEdit_2 is empty.

    Are you really 100% sure? I used PyQt5 and I'm pretty sure self.lineEdit_2.text() == "" would work as expected. Get rid of all your other code and behaviour and check just this in a tiny program?

    @jsulm

    You should rather use https://doc.qt.io/qt-5/qstring.html#isEmpty

    My understanding is PyQt5's QLineEdit.text() returns a Python str rather than a C++ QString anyway. I never found using QString methods of any use in PyQt5.

  • 0 Votes
    4 Posts
    675 Views
    JonBJ

    @Selvajothi
    There could be many causes. I suggest you Google for _dlopen specified procedure. Note that the error you show is on procedure, not on module.

  • 0 Votes
    3 Posts
    458 Views
    I

    @JonB Thank you for interactions. Would you please show me an exact code of for example a PushButton and where to implement it. I am advanced python coder, I just need to see exact steps. Thank you very much.

  • 0 Votes
    4 Posts
    1k Views
    Y

    @KroMignon Well, i try to learn from anothers in every forum, sorry :), @jsulm Thank you Sir, you are a Life saver :)

  • 0 Votes
    2 Posts
    1k Views
    JonBJ

    @Stainopel
    None of this seems relevant. Either you don't really want separate applications but just one and you just want to show the other widget. Or, to run another application as you ask, use Qt's QProcess, or the Python ones for running sub-processes if you prefer, called from your button clicked slot.

  • 0 Votes
    10 Posts
    1k Views
    StainopelS

    @JonB Very Good Suggestion, I used a second variable in the other function to read the opened file(s) from the first function and it did work like a charm. Thanks. Here is an update to the code

    def encryption_hash(self,comboBox_2): index = self.comboBox_2.currentIndex() path = self.fname_E with open(path, 'rb') as f: if index == 2: hasher1 = hashlib.md5() afile1 = f buf1 = afile1.read() a = hasher1.update(buf1) md5 =(str(hasher1.hexdigest())) self.lineEdit_E.setText("File Hash Using MD5: " + md5)