Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.7k Posts
  • Static build is slower than dynamic build

    Solved
    12
    0 Votes
    12 Posts
    877 Views
    P
    Compiled Qt statically with -static-runtime enabled, and now the slowdown is gone. Maybe finding libstdc++ and libgcc was slow. I'll still need to do some more testing, but Im positive that this was the problem
  • How to Build and Install Missing Qt Modules?

    Solved qt3d qtdatavis3d modules qt5
    3
    0 Votes
    3 Posts
    1k Views
    N
    Yup. You can find the packages under Pi Menu > Preferences > Add/Remove Software. Doing a search there will eventually bring up the needed modules. I am still curious as how one builds the modules separately though. Thanks again!
  • Functions of QWidgets used for QTableWidgets

    Unsolved
    2
    0 Votes
    2 Posts
    158 Views
    JonBJ
    @Swati777999 said in Functions of QWidgets used for QTableWidgets: QTableWidgets class is a subclass of QtWidgets. The functions of QWidgets can be used for QTableWidgets objects. Yup. I have found some functions not working in my program. Like what? Yes you can call methods of QWidget on, say, QTableWidget. I have another doubt, can public slots be used as public member functions of a class? ? Yes, public slots are just public methods.
  • QTableView Vs QTableWidget creating a table

    Solved
    3
    0 Votes
    3 Posts
    613 Views
    Swati777999S
    @sierdzio Thanks.
  • Populating a vector of QPieSlices

    Solved
    2
    0 Votes
    2 Posts
    187 Views
    jsulmJ
    @pgiovanni said in Populating a vector of QPieSlices: QPieSlice it is derived from QObject. QObjects are NOT copyable! So, store pointers to QPieSlice in your vector.
  • QT reading Serialport of Arduino

    Solved
    17
    0 Votes
    17 Posts
    4k Views
    M
    Hai everyone. I found some clues about this topic. The serial communication have to enable the DTR (Data Terminal Ready). So this is my current code that I used void SerialPortManager::openSerialPort() { arduino->setPortName("COM8"); arduino->open(QIODevice::ReadWrite); arduino->setBaudRate(QSerialPort::Baud9600); arduino->setDataBits(QSerialPort::Data8); arduino->setParity(QSerialPort::NoParity); arduino->setStopBits(QSerialPort::OneStop); arduino->setFlowControl(QSerialPort::NoFlowControl); arduino->setDataTerminalReady(true); } Actually, I don't know why its working, but some of tutorial it's not a problem without writing setDataTerminalReady
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Document refresh or script earlier than onCompleted

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

    Unsolved
    3
    0 Votes
    3 Posts
    11 Views
  • QGridLayout, help...

    Solved
    2
    0 Votes
    2 Posts
    130 Views
    SPlattenS
    @SPlatten , fixed: [image: 7fbbaefa-22c6-49f5-b484-f8ff77e6e78f.png] XML: <?xml version="1.0" encoding="utf-8"?> <form title="Test form" id="frmTest" hspacing="0" vspacing="0" width="420" height="360" modal="false"> <entry control="listwidget" label="Select" id="enSEL" cols="24" rows="1" mode="single" excludeFromChangeCheck="true" resetPropertiesOnChange="true" eol="true"> <subscriber signal="itemSelectionChanged" target="simon2.js@listWidgetHandler"/> <subscriber signal="currentItemChanged" target="simon2.js@listWidgetChanged"/> </entry> <entry control="lineedit" label="First name" id="enFN" eol="true" cols="24" maxlength="24" accept="alpha_only" dbfield="vcFirstName"/> <entry control="lineedit" label="Surname" id="enSN" eol="true" cols="24" maxlength="24" accept="alpha_only" dbfield="vcSurName"/> <label text="Sex"/> <layout eol="true" height="56" hspacing="0" id="rdoLO" scrollbar="false" type="grid" vspacing="0" width="72"> <buttongroup id="enSEX"> <radiobutton id="rdoM" height="28" text="Male" default="true"/> <radiobutton id="rdoF" height="28" text="Female"/> </buttongroup> </layout> <entry control="textedit" label="Address" id="enADR" eol="true" maxlength="256" accept="alpha_numeric" cols="24" rows="5" dbfield="vcAddress" properties="margin-bottom:16px;"/> <entry control="checkbox" dbfield="intEmployed" eol="true" id="enEmp" label="Employed"/> <layout colspan="2" id="btnbarLO" scrollbar="false" type="horizontal"> <buttongroup id="enBar"> <button id="btnApply" api="applyChanges"> <subscriber signal="clicked" target="simon2.js@applyButton"/> </button> <button id="btnUndo" api="undoChanges"/> <button id="btnOK" api="submitAndClose"/> </buttongroup> </layout> <on saveChanges="Save changes before changing selection?"/> <on setup="simon2.js@setupForm"/> </form>
  • Hdpi support for QCursor in qt6

    Unsolved
    1
    2 Votes
    1 Posts
    306 Views
    No one has replied
  • QButtonGroup reduce width around content?

    Unsolved
    8
    0 Votes
    8 Posts
    729 Views
    SPlattenS
    @JonB , ok, this is my class prototype: typedef std::map<const QString, QButtonGroup*> mpGroups; class clsQtLayout : public QWidget, public clsXMLinterface { private: mpGroups* mmpGroups; QLayout* mpobjLO; QScrollArea* mpobjScroller; public: explicit clsQtLayout(clsXMLnode* pobjNode, QString* pstrCSS , QWidget* pobjParent); ~clsQtLayout(); void addButton(QAbstractButton* pobjButton, const QString& crstrGroup); void addWidget(QWidget *pobjWidget); bool blnIsLayout() { return true; } QButtonGroup* pobjAddGroup(const QString& crstrGroup); QLayout* pobjGetLayout() { return mpobjLO; } QScrollArea* pobjGetScroller() { return mpobjScroller; } }; Implementation: /** * @brief clsQtLayout::clsQtLayout * @param pobjNode : Pointer to XML node * @param pstrCSS : Pointer to CSS * @param pobjParent : Pointer to parent widget */ clsQtLayout::clsQtLayout(clsXMLnode* pobjNode, QString* pstrCSS , QWidget* pobjParent) : QWidget(pobjParent) , clsXMLinterface(pobjNode) , mmpGroups(nullptr) , mpobjLO(nullptr) { Q_ASSERT_X(pobjNode!=nullptr, QString("%1::%1").arg(metaObject()->className() ,metaObject()->className()) .toLatin1().data() , "No node supplied!"); QString strID(pobjNode->strGetAttribute(clsXMLnode::mscszAttrID)) ,strHeight(mpobjNode->strGetAttribute(clsXMLnode::mscszAttrHeight)) ,strHorzSpacing(mpobjNode->strGetAttribute( clsXMLnode::mscszAttrSpacingH)) ,strName ,strType(pobjNode->strGetAttribute(clsXMLnode::mscszAttrType)) ,strVertSpacing(mpobjNode->strGetAttribute( clsXMLnode::mscszAttrSpacingV)) ,strWidth(mpobjNode->strGetAttribute(clsXMLnode::mscszAttrWidth)); strName = QString("%1: %2").arg(clsXMLnode::mscszNameLayout, strType); if ( strID.isEmpty() != true ) { strName += QString(", %1: %2").arg(clsXMLnode::mscszNameID, strID); } clsXMLnode::setObjName(*this, strName); if ( strType.compare(clsXMLnode::mscszLayoutForm) == 0 ) { //Set-up form QFormLayout* pobjForm(new QFormLayout); clsXMLnode::setObjName(*pobjForm, QString("%1, %2").arg(strName , pobjForm->metaObject()->className())); pobjForm->setContentsMargins(0,0,0,0); pobjForm->setSpacing(0); setLayout(pobjForm); //Any spacing to apply? if ( strHorzSpacing.isEmpty() != true ) { int intHorzSpacing(strHorzSpacing.toInt()); if ( intHorzSpacing >= 0 ) { pobjForm->setHorizontalSpacing(intHorzSpacing); } } if ( strVertSpacing.isEmpty() != true ) { int intVertSpacing(strVertSpacing.toInt()); if ( intVertSpacing >= 0 ) { pobjForm->setVerticalSpacing(intVertSpacing); } } mpobjLO = pobjForm; } else if ( strType.compare(clsXMLnode::mscszLayoutGrid) == 0 ) { QGridLayout* pobjGrid(new QGridLayout); clsXMLnode::setObjName(*pobjGrid, QString("%1, %2").arg(strName , pobjGrid->metaObject()->className())); pobjGrid->setContentsMargins(0,0,0,0); pobjGrid->setSpacing(0); setLayout(pobjGrid); mpobjLO = pobjGrid; } else if ( strType.compare(clsXMLnode::mscszLayoutHorizontal) == 0 ) { QHBoxLayout* pobjHBox(new QHBoxLayout); clsXMLnode::setObjName(*pobjHBox, QString("%1, %2").arg(strName , pobjHBox->metaObject()->className())); pobjHBox->setContentsMargins(0,0,0,0); pobjHBox->setSpacing(0); setLayout(pobjHBox); mpobjLO = pobjHBox; } else if ( strType.compare(clsXMLnode::mscszLayoutVertical) == 0 ) { QVBoxLayout* pobjVBox(new QVBoxLayout); clsXMLnode::setObjName(*pobjVBox, QString("%1, %2").arg(strName , pobjVBox->metaObject()->className())); pobjVBox->setContentsMargins(0,0,0,0); pobjVBox->setSpacing(0); setLayout(pobjVBox); mpobjLO = pobjVBox; } mpobjScroller = new QScrollArea; clsXMLnode::setObjName(*mpobjScroller, QString("%1, %2").arg(strName , mpobjScroller->metaObject()->className())); mpobjScroller->setWidget(this); if ( strHeight.isEmpty() != true ) { int intHeight(strHeight.toInt()); if ( intHeight >= 0 ) { mpobjScroller->setFixedHeight(intHeight); } } if ( strWidth.isEmpty() != true ) { int intWidth(strWidth.toInt()); if ( intWidth >= 0 ) { mpobjScroller->setFixedWidth(intWidth); } } if ( pstrCSS != nullptr && pstrCSS->isEmpty() != true ) { mpobjScroller->setStyleSheet(*pstrCSS); } mpobjScroller->setWidgetResizable(true); } /** * @brief clsQtLayout::~clsQtLayout */ clsQtLayout::~clsQtLayout() { if ( mmpGroups != nullptr ) { for( mpGroups::iterator itGrp=mmpGroups->begin(); itGrp!=mmpGroups->end(); itGrp++ ) { QButtonGroup* pobjBtnGrp(itGrp->second); pobjBtnGrp->deleteLater(); } delete mmpGroups; } if ( mpobjScroller != nullptr ) { mpobjScroller->deleteLater(); } if ( mpobjLO != nullptr ) { mpobjLO->deleteLater(); } } /** * @brief clsQtLayout::addButton * @param pobjButton : Pointer to button * @param crstrGroup : Constant reference to button group */ void clsQtLayout::addButton(QAbstractButton* pobjButton, const QString& crstrGroup) { if ( pobjButton == nullptr ) { return; } if ( crstrGroup.isEmpty() != true ) { QButtonGroup* pobjBtnGrp(pobjAddGroup(crstrGroup)); if ( pobjBtnGrp != nullptr ) { pobjBtnGrp->addButton(pobjButton); } } if ( mpobjLO != nullptr && mpobjNode != nullptr ) { QString strType(mpobjNode->strGetAttribute(clsXMLnode::mscszAttrType)); if ( strType.compare(clsXMLnode::mscszLayoutForm) == 0 ) { QFormLayout* pobjForm(qobject_cast<QFormLayout*>(mpobjLO)); if ( pobjForm != nullptr ) { pobjForm->addWidget(pobjButton); } } else if ( strType.compare(clsXMLnode::mscszLayoutGrid) == 0 ) { QGridLayout* pobjGrid(qobject_cast<QGridLayout*>(mpobjLO)); if ( pobjGrid == nullptr ) { return; } //Get a pointer to the widget based on its type clsXMLinterface* pobjInterface(reinterpret_cast<clsXMLinterface*> (pobjButton)); clsXMLnode* pobjNode(nullptr); if ( pobjInterface != nullptr ) { pobjNode = pobjInterface->pobjGetNode(); } if ( pobjNode == nullptr ) { return; } QString strColumnNo(pobjNode->strGetAttribute( clsXMLnode::mscszAttrColumnNo)) ,strRowNo(pobjNode->strGetAttribute( clsXMLnode::mscszAttrRowNo)); int intColumn(-1), intRow(-1); if ( strColumnNo.isEmpty() != true ) { intColumn = strColumnNo.toInt(); } if ( strRowNo.isEmpty() != true ) { intRow = strRowNo.toInt(); } if ( intColumn != -1 && intRow != -1 ) { pobjGrid->addWidget(pobjButton, intRow, intColumn); } } else if ( strType.compare(clsXMLnode::mscszLayoutHorizontal) == 0 ) { QHBoxLayout* pobjHBox(qobject_cast<QHBoxLayout*>(mpobjLO)); if ( pobjHBox != nullptr ) { pobjHBox->addWidget(pobjButton); } } else if ( strType.compare(clsXMLnode::mscszLayoutVertical) == 0 ) { QVBoxLayout* pobjVBox(qobject_cast<QVBoxLayout*>(mpobjLO)); if ( pobjVBox != nullptr ) { pobjVBox->addWidget(pobjButton); } } } } /** * @brief clsQtLayout::addWidget * @param pobjWidget Pointer to widget to add */ void clsQtLayout::addWidget(QWidget *pobjWidget) { if ( pobjWidget != nullptr ) { QLayout* pobjLayout(layout()); if ( pobjLayout != nullptr ) { pobjLayout->addWidget(pobjWidget); } } } /** * @brief clsQtLayout::pobjAddGroup * @param crstrGroup : Group ID * @return Pointer to QButtonGroup */ QButtonGroup* clsQtLayout::pobjAddGroup(const QString& crstrGroup) { QButtonGroup* pobjBtnGrp(nullptr); if ( crstrGroup.isEmpty() != true ) { if ( mmpGroups == nullptr ) { mmpGroups = new mpGroups; } mpGroups::iterator itGrp(mmpGroups->find(crstrGroup)); if ( itGrp != mmpGroups->end() ) { pobjBtnGrp = itGrp->second; } else { pobjBtnGrp = new QButtonGroup(this); clsXMLnode::setObjName(*pobjBtnGrp, QString("%1, %2: %3") .arg(objectName() ,pobjBtnGrp->metaObject()->className() ,crstrGroup)); mmpGroups->insert(std::make_pair(crstrGroup, pobjBtnGrp)); } } return pobjBtnGrp; } Sample of setting of the XML: <layout id="rdoLO" height="56" hspacing="0" scrollbar="false" eol="true" type="grid" vspacing="0" properties="QLayout {background-color:#ffaaaa;}"> <buttongroup id="enSEX"> <radiobutton id="rdoM" height="28" text="Male" default="true"/> <radiobutton id="rdoF" height="28" text="Female"/> </buttongroup> </layout> And a screenshot of this: [image: e32b76a2-4129-4f04-8149-a0fc917e8aaf.png] Would setting the size policy of the layout to Minimum help ? Nope, tried setting size policy on containing widget and then scroller, neither worked using: setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); No difference at all.
  • QMap iterator Bug??

    Solved
    21
    0 Votes
    21 Posts
    6k Views
    Christian EhrlicherC
    @JoeCFD When you're at the point where you really need to worry about a speed difference between those implementations you should write your own implementation of the problematic container. You will never notice if a running program is using c++ or Qt or boost or whatever containers.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    8 Views
    No one has replied
  • Singal is no longer transmitted when QComboBox index is changed

    Solved
    5
    0 Votes
    5 Posts
    345 Views
    ?
    Thanks for all your help. @mchinand tip was the solution. Thanks!
  • How to record and play RTSP stream from ip camera

    Unsolved
    13
    0 Votes
    13 Posts
    4k Views
    A
    @Stuhalsky-Alex I can't switch to Qt 6 yet, I'm stuck with 5.12 I have alternatives ways to record the stream, but using a QMediaRecorder seemed easy enough to set-up and as it is well-integrated into Qt it made everything easier. I'll try to have a look at GStreamer to see if it can workaround this issue. Thanks for your answer anyway :)
  • qmake replace function not working

    Unsolved
    1
    0 Votes
    1 Posts
    322 Views
    No one has replied
  • no pictures in helpfile

    Solved
    8
    0 Votes
    8 Posts
    528 Views
    D
    Hi, help from compressed archive works no matter, whether the *.html-files where built by qdoc, doxygen or are handwritten. If firefox can display the page as local file, then it should be ready for help-browser as well. New changes for index and keyword support: I added *.qhp to archive. That file already contains all necessary informations. So I did it like QHelpEngine: create Standard-widgets, which can be included in some page layout. I created a help-"dialog" a dockable, which can be used floating or integrated into mainwindow. HelpDialog::HelpDialog(QWidget* parent) : QDockWidget(tr("Help"), parent) , he(new HelpEngine(Core().helpFilename(), this)) , tb(new HTMLBrowser(*he)) , cw(static_cast<HelpContentWidget*>(he->contentWidget())) , kw(static_cast<HelpKeywordWidget*>(he->keywordWidget())) { setObjectName("HelpDialog"); tb->setMinimumWidth(830); setMinimumWidth(1100); QSplitter* sh = new QSplitter(Qt::Horizontal, this); QTabWidget* tw = new QTabWidget(sh); sh->addWidget(tw); sh->addWidget(tb); tw->addTab(cw, tr("Content")); tw->addTab(kw, tr("Keywords")); setWidget(sh); connect(cw, &QTreeWidget::currentItemChanged, this, &HelpDialog::contentItemChanged); connect(kw, &QListWidget::currentItemChanged, this, &HelpDialog::keywordItemChanged); } void HelpDialog::contentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *) { const QString& page = current->data(1, Qt::DisplayRole).toString(); tb->setSource(page); } void HelpDialog::keywordItemChanged(QListWidgetItem *current, QListWidgetItem *) { const QString& page = current->toolTip(); tb->setSource(page); } [image: 709eaf36-6269-4065-9bbb-34645bf9315c.jpg] Here the sources. First the content-widget, a subclass of QTreeWidget: class HelpContentWidget : public QTreeWidget { Q_OBJECT public: explicit HelpContentWidget(QWidget* parent = nullptr); virtual ~HelpContentWidget(); void setFolderIcon(const QIcon& ico); void setHelpIcon(const QIcon& ico); void parse(const QByteArray& ba); protected: QTreeWidgetItem* createItem(const QDomElement& e, QTreeWidgetItem* parent); QTreeWidgetItem* processElement(const QDomElement& e, QTreeWidgetItem* parent); void processChildren(const QDomElement& e, QTreeWidgetItem* parentItem = nullptr); void processAttributes(const QDomElement& e, QTreeWidgetItem* item); private: int level; QIcon folderIcon; QIcon helpIcon; }; ... and its implementation: HelpContentWidget::HelpContentWidget(QWidget* parent) : QTreeWidget(parent) { header()->setStretchLastSection(true); setHeaderLabel(tr("Title")); } HelpContentWidget::~HelpContentWidget() { } void HelpContentWidget::parse(const QByteArray& ba) { QDomDocument doc; doc.setContent(ba); QDomNodeList links = doc.elementsByTagName("toc"); level = 0; clear(); for (int i=0; i < links.count(); ++i) { QDomNode link = links.item(i); qDebug() << "\n"; qDebug() << "check entry #" << i; if (link.isElement()) { QDomElement e = link.toElement(); processChildren(e); } } } void HelpContentWidget::processAttributes(const QDomElement& e, QTreeWidgetItem* item) { int mx = e.attributes().count(); qDebug() << "processAttributes ..."; if (mx > 0) { qDebug() << "element has" << mx << "attributes"; for (int i=0; i < mx; ++i) { const QDomNode& n = e.attributes().item(i); qDebug() << "\tattribute:" << n.nodeName() << " => " << n.nodeValue(); if (n.nodeName() == "title") item->setText(0, n.nodeValue()); else if (n.nodeName() == "ref") item->setText(1, n.nodeValue()); } } else qDebug() << "element has NO attributes"; } void HelpContentWidget::processChildren(const QDomElement& e, QTreeWidgetItem* parent) { qDebug() << "processChildren ... (level:" << level++ << ")"; for (QDomNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) { if (n.isElement()) { qDebug() << "child is Element"; processElement(n.toElement(), parent); } } --level; } QTreeWidgetItem* HelpContentWidget::createItem(const QDomElement &e, QTreeWidgetItem *parent) { QTreeWidgetItem* item; if (parent) item = new QTreeWidgetItem(parent); else item = new QTreeWidgetItem(this); item->setIcon(0, folderIcon); processAttributes(e, item); return item; } QTreeWidgetItem* HelpContentWidget::processElement(const QDomElement& e, QTreeWidgetItem* parent) { qDebug() << "processElement - tag:" << e.tagName() << "text:" << e.text(); QTreeWidgetItem* item = nullptr; if (e.tagName() == "section") { item = createItem(e, parent); processChildren(e, item); } return item; } void HelpContentWidget::setFolderIcon(const QIcon &ico) { folderIcon = ico; } void HelpContentWidget::setHelpIcon(const QIcon &ico) { helpIcon = ico; } ... followed by the keywordWidget: class HelpKeywordWidget : public QListWidget { Q_OBJECT public: explicit HelpKeywordWidget(QWidget* parent = nullptr); virtual ~HelpKeywordWidget(); void parse(const QByteArray& ba); void setIcon(const QIcon& icon); protected: void processChildren(const QDomElement& e); private: QIcon icon; }; with this implementation: HelpKeywordWidget::HelpKeywordWidget(QWidget* parent) : QListWidget(parent) { } HelpKeywordWidget::~HelpKeywordWidget() { } void HelpKeywordWidget::parse(const QByteArray &ba) { QDomDocument doc; doc.setContent(ba); QDomNodeList links = doc.elementsByTagName("keywords"); clear(); for (int i=0; i < links.count(); ++i) { QDomNode link = links.item(i); qDebug() << "\n"; qDebug() << "check entry #" << i; if (link.isElement()) { QDomElement e = link.toElement(); processChildren(e); } } } void HelpKeywordWidget::processChildren(const QDomElement& e) { qDebug() << "processChildren ... "; for (QDomNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) { if (n.isElement()) { qDebug() << "child is Element"; QDomElement elem = n.toElement(); QListWidgetItem* item = new QListWidgetItem(); int mx = elem.attributes().count(); item->setIcon(icon); for (int i=0; i < mx; ++i) { const QDomNode& n = elem.attributes().item(i); if (n.nodeName() == "name") item->setText(n.nodeValue()); else if (n.nodeName() == "ref") item->setToolTip(n.nodeValue()); } addItem(item); } else if (n.isEntity()) qDebug() << "child is Entity"; else if (n.isAttr()) qDebug() << "child is Attribute"; else if (n.isText()) qDebug() << "child is Text"; } } void HelpKeywordWidget::setIcon(const QIcon &icon) { this->icon = icon; } Creation of helpfile is done with a little bash-script: #!/bin/bash project=FalconView qdoc ${project}.qdocconf cp ${project}.qhp html cd html zip -u9 ../FalconView.qzh *.html images/* FalconView.qhp I think that this solution can be used to create a helper solution for small applications with the least possible effort.
  • Compilation error on Q_DISABLE_COPY_MOVE

    Solved
    5
    0 Votes
    5 Posts
    2k Views
    Joel BodenmannJ
    Alright - I checked the docs and Q_DISABLE_COPY_MOVE exists only since Qt 5.13 which leads to this problem. Thank you for your help!
  • Problem in QVariantList in Qt 5.12?

    Solved
    20
    0 Votes
    20 Posts
    2k Views
    M
    @Christian-Ehrlicher My mistake: I could not use the right runtime library switch because I had "Ignore specific default libraries" set! Now I recompiled in debug with /MT and it works! Thanks a lot.