Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.7k Posts
  • Are singletons considered good or bad for some config

    Unsolved
    13
    0 Votes
    13 Posts
    2k Views
    kshegunovK
    @Thank-You said in Are singletons considered good or bad for some config: So I wanted to know how it does and work and is it good or not. But I wanted to know other methods only I was intending not to take part in this one, but what can I say, I'm a masochist. The Qt way™ is what Christian posted, however his comment is true only partially. The initialization of the global is thread-safe, the object behind is not. So if one assumes that the variable is going to be used from multiple threads then making the construction/destruction thread-safe is only half the job. So I'll preach what I usually preach: don't use a singleton if you can avoid it. It's more trouble than it's worth, and ultimately it's worth very little to begin with.
  • Docking widgets in the parent widget.

    Unsolved
    16
    0 Votes
    16 Posts
    1k Views
    JonBJ
    @jenya7 said in Docking widgets in the parent widget.: I consider to stick to a console application. That would seem to be a most retrograde step! Your current application achieves (or attempts to achieve) an awful lot more than a response-by-response command-line program would. For a first UI application it does quite a lot (tabs, frames, widgets...), so it might be expected that it would take a bit of time to get it right. Effort which will aid you in future UI additions. So as @jsulm says from where you are now it would be good if you choose to persist with the UI.
  • How to popup a message box when QAbstractModel::setData got invalid data?

    Solved
    17
    0 Votes
    17 Posts
    1k Views
    SGaistS
    @jronald said in How to popup a message box when QAbstractModel::setData got invalid data?: How to disable "Enter" conditionally? Tie it to a validator's validity state. @jronald said in How to popup a message box when QAbstractModel::setData got invalid data?: A message box can tell the user what's wrong, it is helpful. A UI that is explicit with regard to what it expects is better. Do you really like to enter information in an application to just to have a message tell you that you have to do it all over again because of various constraints ? Constraints that are usually lost as you need to close the dialog to access the UI again ? Make things simple and clear: If you need a number in a range use a QSpinBox If you need a line of text with requirements use a QLineEdit with a suitable validator. Add an icon beside it with a QToolTip giving the expected input or a label underneath it with that advice.
  • Connecting two QWidget with QMouseEvents

    Solved
    3
    0 Votes
    3 Posts
    275 Views
    W
    @jsulm Thanks, I can do this!
  • 0 Votes
    1 Posts
    382 Views
    No one has replied
  • Debugging in Qt program in Qt Creator

    Unsolved
    3
    0 Votes
    3 Posts
    276 Views
    A
    I have added the following to my .pro file . message ("removed all subdirs here Nov 17 no differnce ") SUBDIRS += \ # ../../../../../BACKUP/CAT-28-3/PROJECTS/CAT_FT857_BLUETOOTH/CAT_FT857_BLUETOOTH_MAIN_PROJECT/TEST_MDI/TEST_MDI.promessage(:dupressdd complier warningsd \ # ../../EXAMPLES_COPY_5.x/Examples/Qt-6.2.0/bluetooth/btchat/btchat.pro \ # ../../Examples/Qt-5.15.2/bluetooth/btscanner/btscanner.pro message("supress all warnings ") QMAKE_CXXFLAGS += -w #QMAKE_CXXFLAGS_WARN_OFF message ("verbose output compiler ") QMAKE_LFLAGS += -v message ("verbose output linker ") QMAKE_CXXFLAGS += -Wl, --verbose message (" disable qDebug messages") #//CONFIG += console #DEFINES += QT_NO_DEBUG_OUTPUT It is somewhat redundant or stupid , take your pick. I use heavily #ifdef BYPASS useless old code but sometime prevents making same mistake #endif then old stand by #define DEBUG #ifdef DEBUG trace / debug notes .... #endif Best debug tool for(;;) comment your code PS Anybody care to add how to "remove all break points", senior moment. PPS I cannot be held responsible for the messed-up text...
  • Modbus Com in different thread

    Solved
    12
    0 Votes
    12 Posts
    1k Views
    S
    because m_modbusDevice is created in the constructor of ModbusCom and ModbusCom is instanced in mainthread. So m_modbusDevice is the object belonging the mainthread, and its timeout QTimer can't be worked propertly. To fix that, try to create the m_modbusDevice in m_thread, for exaple: class ModbusCom { QModbusRtuSerialMaster* m_modbusDevice; void initModbus() { m_modbusDevice=new QModbusRtuSerialMaster();//created in m_thread //other initialization code... } } connect(SerialComWorker,SIGNAL(startModbus()), m_modbus,SLOT( initModbus()); //then initModbus() function will excute in m_thread and m_modbusDevice will be m_thread's obejct. m_thread.start(); emit startModbus();
  • QTcpSocket can not bind to specified net card

    Solved
    7
    0 Votes
    7 Posts
    657 Views
    C
    @Christian-Ehrlicher I have sovled the problem by your suggestion,thanks a lot
  • How to use resource files without using .ui or form files in Qt?

    Unsolved
    12
    0 Votes
    12 Posts
    836 Views
    Pl45m4P
    @Swati777999 Show what you've done so far. Have you added your rc-file to your project?
  • This topic is deleted!

    Unsolved
    3
    0 Votes
    3 Posts
    19 Views
  • How to get QT's Debug information in msvc Vs2015?

    Unsolved
    3
    0 Votes
    3 Posts
    416 Views
    SGaistS
    Hi, It depends. Unless you need some special processing done by OpenCV you might want to consider using the QtMultimedia module.
  • Set a stylesheet for QColorDialog

    Solved
    9
    0 Votes
    9 Posts
    1k Views
    S
    Hi, so I just now realised, that I've made a mistake in my code example. Everytime you click cancel the color that it returns is black. EDIT: It's a problem because I'm setting a widgets color, and when I click cancel, it sets without me wanting it to. Here it's fixed: QString color; QColorDialog pick; pick.setStyleSheet("stylesheet"); pick.setCurrentColor("10, 255, 10"); //optional if (pick.exec() == QColorDialog::Accepted) { QColor const color = pick.selectedColor().name(); color = color.name(); qDebug() << color; } Another EDIT: Here's an example of 2 different stylesheets: Light mode: QColorDialog {background-color: rgb(244, 244, 244);} QPushButton {background-color: rgb(244, 244, 244); color: black;} QLabel {background-color: rgb(244, 244, 244); color: black;} QLineEdit {background-color: white; color: black;} QSpinBox {background-color: white; color: black;} Dark mode: QColorDialog {background-color: rgb(6, 6, 14);} QPushButton {color: rgb(211, 213, 201); background-color: rgb(36, 36, 44);} QLabel {color: rgb(211, 213, 201); background-color: rgb(6, 6, 14);} QLineEdit {color: rgb(211, 213, 201); background-color: rgb(36, 36, 44);} QSpinBox {color: rgb(211, 213, 201); background-color: rgb(36, 36, 44);}
  • REST request with an regular expressions in a URL

    Unsolved
    9
    0 Votes
    9 Posts
    3k Views
    M
    @Beatnicker said in REST request with an regular expressions in a URL: "http://192.168.0.125:8086/rest/channel/.*/.*Temperature" It's interesting that only your first wildcard in your url is being removed when sending via Qt. Not sure why that is though.
  • Question with Debugger used in QtCreator

    Unsolved
    2
    0 Votes
    2 Posts
    187 Views
    L
    One other point, when I single step the same code using VS2019, it steps over properly. I wonder if some setting is missing.
  • Adding QT Plugin WSL in visual studio

    Unsolved
    1
    0 Votes
    1 Posts
    224 Views
    No one has replied
  • How scroll to a specific html tag in QTextEdit?

    Unsolved
    4
    0 Votes
    4 Posts
    473 Views
    artwawA
    @abdoll78 solution is to parse your source text, add anchors in it, then set.
  • Convert a QDate to BCD Format (Binary-coded decimal) for QByteArray

    Solved
    3
    0 Votes
    3 Posts
    933 Views
    P
    Wow ok, I expected my code to be too complicated. But not at this point ^^. Thanks and have a nice day.
  • Invisible QLineEdit receive Focus?!?

    Solved
    11
    0 Votes
    11 Posts
    1k Views
    D
    Just to close this: I solved the problem with this solution
  • Creating mockobject of Qfile by replacing Qbuffer possible?

    Solved
    4
    0 Votes
    4 Posts
    249 Views
    C
    Thank you so much for explaining! It works to pass QFile and QBuffer like that.
  • Which control to use for this kind of report?

    Solved
    4
    0 Votes
    4 Posts
    454 Views
    D
    @mpergand, forgot that! used that in QueryLite. With these: tree->header()->setSectionResizeMode(0, QHeaderView::Stretch); tree->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); tree->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents); no need to calculate the width of text in columns and I can get rid of that resizeEvent.