Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.4k Posts
  • Compiling Qt for WebAssembly

    Unsolved
    2
    0 Votes
    2 Posts
    315 Views
    SGaistS
    Hi, What do you get if you pass the -v argument to configure ?
  • Version for Qt Libs like qopcua

    Solved
    2
    0 Votes
    2 Posts
    307 Views
    SGaistS
    Hi, No, there's no coincidence here. The module is part of the Qt release so it follows the version numbering. Side note: GitHub is just a mirror, the official repositories are on https://code.qt.io
  • How to autofit widget size and position to a cell in QTreeWidget?

    Solved
    2
    0 Votes
    2 Posts
    2k Views
    F
    myTree->resizeColumnToContent(0);
  • How to properly manage a Multi-Page application (without QStackedWidget)

    Solved
    13
    0 Votes
    13 Posts
    4k Views
    F
    I finally found a solution #include <QFrame> class AbstractPage : public QFrame { Q_OBJECT public: explicit AbstractPage(QWidget *parent = nullptr){}; virtual AbstractPage* (*getFactory())() = 0; }; An exemple of a Page #include "abstractframe.h" class Page1 : public AbstractFrame { Q_OBJECT public: explicit Page1(QWidget *parent = nullptr); inline static AbstractFrame* factory(){return new Page1;}; inline AbstractFrame* (*getFactory())() {return &Page1::factory;}; private slots: void onButtonClicked(bool); signals: void frameChanged(AbstractFrame*); }; And generate a new Page using AbstractFrame *(*previousFrame)() = mCenterFrame->getFactory(); // and after create the Frame mCenterFrame = previousFrame();
  • How to restore the default of columns in a QTreeView

    Unsolved
    2
    0 Votes
    2 Posts
    447 Views
    JonBJ
    @Qt-Enthusiast There is no "reset the column width and order" for a tree view (QHeaderView), it doesn't know its initial state. Other than throwing it away and creating a new one, it would be up to you to save the initial order/widths and reset to that yourself in code. You might leverage QHeaderView::save/restoreState to help you, but still requires you to take that action if that's what you want.
  • How to get QTreeWidgetItem position?

    Solved
    6
    0 Votes
    6 Posts
    1k Views
    VRoninV
    itemWidget is not the way to go. the delegate is the scalable solution
  • Cloning source from git: asked for username

    Solved
    3
    0 Votes
    3 Posts
    431 Views
    M
    Thanks. So the command I needed was git clone git://code.qt.io/qt/qt5.git
  • Maximize not working correctly

    Solved
    3
    0 Votes
    3 Posts
    479 Views
    D
    OK, I gave bad info. The window manager question made me realize that in my frustration, I just ran it under LXDE on my notebook, not Gnome. It does fail in Gnome on my i3 notebook. The window behaves correctly with LXDE in all instances. I can just use that, but I do still want to find out what was causing the issues in the Gnome shell. Thanks for the clarity. This was the product of a full head after a long week.
  • QSettings problem when input file is a link

    Solved windows symlink qsettings
    16
    0 Votes
    16 Posts
    4k Views
    S
    Replying to myself: The bugrepport said is is fixed for 5.10.1 https://bugreports.qt.io/browse/QTBUG-64121 And it can be made to work with correct folder permissions : $ ls -ld /etc/config/ drwxr-xr-x 2 root root 4096 avril 1 11:15 /etc/config/ $ sudo chgrp pi /etc/config/ $ sudo chmod g+w /etc/config/ $ ls -ld /etc/cleandrop/ drwxrwxr-x 2 root pi 4096 avril 1 11:15 /etc/config/ resolving simlink doesn't helps // resolve symlink // https://bugreports.qt.io/browse/QTBUG-64121 QFileInfo info(_configuration_file); if (info.isSymLink()) _configuration_file = info.symLinkTarget(); So I removed this fix, and fixed the folder permission and it worked.
  • Running QProcess in a loop

    Solved
    16
    0 Votes
    16 Posts
    3k Views
    G
    @SGaist I created a new class for the gpio. I am working on a project in which i have to monitor 4 different switches and play different sounds whenever any switch is pressed. I am attaching the classes which i created #ifndef F81866_H #define F81866_H #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <sys/time.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/io.h> /* linux-specific */ #ifdef __GLIBC__ # include <sys/perm.h> #endif #define F81866_REG_LD 0x07 #define F81866_UNLOCK 0x87 #define F81866_LOCK 0xAA #define F81866_CFG_GPIO 0x06 #define F81866_CFG_WDT 0x07 static unsigned short F81866_PORT_INDEX = 0x004eL; static unsigned short F81866_PORT_DATA = 0x004fL; static unsigned int ChipIDTab[] = { 0x19341010, // F81866 0x19340704, // F81865 0x19341502, // F81964/F81962/F81966/F81967 }; class f81866 { public: f81866(); void f81866_unlock(void); void f81866_lock(void); unsigned char f81866_read(unsigned char bREG); void f81866_write(unsigned char bREG, unsigned char bVal); void f81866_set_logicdevice(unsigned char bDev); int f81866_init(); }; #endif // F81866_H C file for the above header #include "f81866.h" f81866::f81866() { } void f81866::f81866_unlock() { outb(F81866_UNLOCK, F81866_PORT_INDEX); outb(F81866_UNLOCK, F81866_PORT_INDEX); } void f81866::f81866_lock() { outb(F81866_LOCK, F81866_PORT_INDEX); } unsigned char f81866::f81866_read(unsigned char bREG) { unsigned char bRES = (unsigned char)-1; f81866_unlock(); outb(bREG, F81866_PORT_INDEX); bRES = inb(F81866_PORT_DATA); f81866_lock(); return bRES; } void f81866::f81866_write(unsigned char bREG, unsigned char bVal) { f81866_unlock(); outb(bREG, F81866_PORT_INDEX); outb(bVal, F81866_PORT_DATA); f81866_lock(); } void f81866::f81866_set_logicdevice(unsigned char bDev) { f81866_write(F81866_REG_LD, bDev); } int f81866::f81866_init() { int nID = 0; int i; unsigned char *pbID = (unsigned char *)&nID; //fintek = 0x1934L, f81866 chip id = 0x10L pbID[1] = f81866_read(0x20L); pbID[0] = f81866_read(0x21L); pbID[3] = f81866_read(0x23L); pbID[2] = f81866_read(0x24L); for (i=0; i<(sizeof(ChipIDTab)/sizeof(ChipIDTab[0])); i++ ) if ( nID == ChipIDTab[i] ) return 0; F81866_PORT_INDEX = 0x002eL; F81866_PORT_DATA = 0x002fL; nID = 0; pbID[1] = f81866_read(0x20L); pbID[0] = f81866_read(0x21L); pbID[3] = f81866_read(0x23L); pbID[2] = f81866_read(0x24L); for (i=0; i<(sizeof(ChipIDTab)/sizeof(ChipIDTab[0])); i++ ) if ( nID == ChipIDTab[i] ) return 0; return -1; } The other class #ifndef F81866_GPIO_H #define F81866_GPIO_H #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <sys/io.h> /* linux-specific */ #define F81866_CFG_GPIO 0x06 class f81866_gpio { public: f81866_gpio(); int getGPI(int nIndex); void setGPO(int nIndex, int nValue); void setDirection(int nIndex, int nValue); void initGPIO(void); }; #endif // F81866_GPIO_H c file for the above header #include "f81866_gpio.h" #include "f81866.h" f81866_gpio::f81866_gpio() { } int f81866_gpio::getGPI(int nIndex) { f81866 classObj; unsigned char bRES = 0; nIndex &= 7; //nIndex input = 0~3 classObj.f81866_set_logicdevice(F81866_CFG_GPIO); //select GPIO logic-device bRES = classObj.f81866_read(0x8AL); //read state from input-state return (bRES & (1 << nIndex)) ? 1 : 0; } void f81866_gpio::setGPO(int nIndex, int nValue) { unsigned char bRES = 0; f81866 classObj; nIndex &= 7; //nIndex inut = 0~7 nValue = nValue ? 1 : 0; classObj.f81866_set_logicdevice(F81866_CFG_GPIO); //select GPIO logic-device bRES = classObj.f81866_read(0x8AL); //read state from input-state bRES &= ~(1 << nIndex); //clean old value bRES |= (nValue << nIndex); //set new value classObj.f81866_write(0x89L, bRES); //write to output-data } void f81866_gpio::setDirection(int nIndex, int nValue) { unsigned char bTMP; f81866 classObj; nIndex &= 7; nValue = nValue ? 1 : 0; classObj.f81866_set_logicdevice(F81866_CFG_GPIO); //select GPIO logic-device bTMP = classObj.f81866_read(0x88L); //read current direction set bTMP &= ~(1 << nIndex); //clean old direction set bTMP |= (nValue << nIndex); //set new direction classObj.f81866_write(0x88L, bTMP); //setvalue } void f81866_gpio::initGPIO() { unsigned char bTMP; f81866 classObj; classObj.f81866_set_logicdevice(F81866_CFG_GPIO); //select GPIO logic-device bTMP = classObj.f81866_read(0x30L); bTMP |= 1; //enable GPIO classObj.f81866_write(0x30L, bTMP); //default GPIO 0~3 is input. setDirection(4, 0); //GPIO4 (IN0) set in setDirection(5, 0); //GPIO5 (IN1) set in setDirection(6, 0); //GPIO6 (IN2) set in setDirection(7, 0); //GPIO7 (IN3) set in } Function to check the GPIO (I call this function from my timer) void pisUser::check_gpio_status() { int gpioVal = 0; f81866_gpio f818Obj; QStringList list; QString audioStr, processStr, filePath = "/home/fiem/Desktop/DIO/Output.txt"; if(gpioCheckStatus == 3) gpioCheckStatus = 2; gpioVal = f818Obj.getGPI(gpioCheckStatus); if(gpioVal == 0) { processStr = QString("Emergency in room %1").arg(gpioCheckStatus); QFont engFont = QFont("Arial Black"); engFont.setPointSize(80); ui->infoLabel->setFont(engFont); ui->infoLabel->setText(processStr); list.clear(); audioStr = QString("/home/fiem/Sound/Audio/gpio%1.mp3").arg(gpioCheckStatus); list.append(audioStr); playDirectAudio(list,1, true); } gpioCheckStatus--; if(gpioCheckStatus < 2 || gpioCheckStatus > 6) gpioCheckStatus = 6; }
  • 0 Votes
    4 Posts
    1k Views
    DoohamD
    @jsulm Hi, thanks for your answer and sorry for my delay, I haven't login in the forum during the weekend. You are right, I eliminated this line and I didn't get this trouble.
  • QSliders linked together

    Unsolved qslider mousemove
    6
    0 Votes
    6 Posts
    2k Views
    MasterBLBM
    Thanks for trying @Kent-Dorfman , but I don't know Python so the example is useless for me. @SGaist ActionTriggered seems to work better: void StepSlider::mouseMoveEvent(QMouseEvent *event) { int valueBefore = value(); QSlider::mouseMoveEvent(event); int valueDelta = value() - valueBefore; if (event->modifiers() == Qt::ControlModifier && valueDelta != 0) { mirroredSlider->triggerAction(valueDelta > 0 ? QAbstractSlider::SliderSingleStepAdd : QAbstractSlider::SliderSingleStepSub); } qDebug() << objectName() << " value delta:" << valueDelta; } though in some situations mirroredSlider is not incremented/decremented properly - but that may be related to my sliders in the testbed project doesn't have properly set stuff to allow change values only by stepSize = 5
  • How to realize the cancel operation of setting/option dialog?

    Unsolved
    2
    0 Votes
    2 Posts
    220 Views
    K
    @Limer I think you will find that is really the only way to do it. Have local values in the dialog and only update the real ones when the user clicks OK. Or, only transfer the value in the controls when the user clicks OK.
  • How to find the nearest value in a QMap ?

    Unsolved
    17
    0 Votes
    17 Posts
    4k Views
    Q
    @VRonin :Thank you Ronin.
  • QList Help

    Solved
    7
    0 Votes
    7 Posts
    629 Views
    R
    Did that, And it is working just perfectly. Thank you for help.
  • Question about software updater applications

    Solved
    6
    0 Votes
    6 Posts
    565 Views
    Cobra91151C
    Ok. I have found some: https://www.reddit.com/r/sysadmin/comments/9nnkn5/software_update_alertsfeed/
  • Identifying item from QModelIndex?

    Unsolved
    5
    0 Votes
    5 Posts
    502 Views
    SGaistS
    @SRaD said in Identifying item from QModelIndex?: @Christian-Ehrlicher Yes, I have a class that is derived from QAbstractItemModel. When you ask if it returns something valid, what are you referring to there? Except I'm not Christian ;-) Yes that's what I'm referring to.
  • QCheckBox's not changing state?

    Unsolved
    8
    0 Votes
    8 Posts
    1k Views
    S
    @Christian-Ehrlicher My getChecked looks like the following: bool MyTreeItem::getChecked() const { return checked; } void MyTreeItem::setChecked(bool set) { checked = set;; } Not sure about edit role && check state in one place. I thought if it was a checkbox, it had to be editable, and I thought setChecked() is where I needed to store it.
  • Guard sentinels for slots?

    Unsolved
    3
    0 Votes
    3 Posts
    447 Views
    JonBJ
    @Kent-Dorfman As @JKSH says you are still responsible for writing explicit code if you want this check. Doubtless you're well aware already, but (a) you could have this in debug/development code only if you trust to skip it in production and (b) personally in some shape or form I'd implement via, say, a function-scoped local variable whose constructor sets and destructor clears the inSlot so that you don't have to worry about putting a return in the middle of your code or an exception being raised etc.
  • QWidget add to QScrollArea

    Unsolved
    4
    0 Votes
    4 Posts
    525 Views
    JonBJ
    @jondoe So you will write "copy" code to create the new widgets from the yellow widget you have downward into its content. There is (deliberately) no QWidget copy constructor, so you will create new widgets via new QWidget/QLabel/QOushbutton and it is your job to copy whatever attributes are currently on the old widgets into the new widgets, e.g. color, size etc. (e.g. see https://www.qtcentre.org/threads/26546-Deep-copy-of-widget-hierarchy for confirmation that this is the way to go) If you don't want to have to know what the children are to start with, you can use one of the QObject::findChildren overloads inherited by QWidget to discover all children programmatically.