Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.7k Topics 458.0k Posts
  • Qt and pkg-config

    Unsolved
    12
    0 Votes
    12 Posts
    2k Views
    SGaistS
    Qt has support for pkg-config both to use it to link to libraries as well as for the lib template. From the looks of it, on Debian, there are .pc files available for the various Qt modules.
  • Experimenting with the layouts

    Unsolved
    3
    0 Votes
    3 Posts
    280 Views
    JoeCFDJ
    Try it in designer which has preview ==>Form==>Preview in==>Fusion Style to make sure the layouts are right and then generate your C++ code.
  • QScreen returning the wrong size for my monitor

    Unsolved
    6
    0 Votes
    6 Posts
    3k Views
    M
    @feistykittykat Thank you very much! That worked for me as well. Was driving me nuts that it used to work when I was doing 5.x development and since going to 6.2.1 I have found a lot of gotchas in my code!
  • Static build is slower than dynamic build

    Solved
    12
    0 Votes
    12 Posts
    898 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
    2k 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
    160 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
    620 Views
    Swati777999S
    @sierdzio Thanks.
  • Populating a vector of QPieSlices

    Solved
    2
    0 Votes
    2 Posts
    188 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
    5k 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
    107 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
    133 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
    312 Views
    No one has replied
  • QButtonGroup reduce width around content?

    Unsolved
    8
    0 Votes
    8 Posts
    749 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
    352 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
    5k 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
    325 Views
    No one has replied