Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.8k Posts
  • Qt6 QCalendarWidget days too wide

    Unsolved
    3
    1 Votes
    3 Posts
    245 Views
    W
    @hskoglund I think in my case it may be a response to the scale factor. My Linux distro is configured for a 2X scale of all fonts. If so this could mean that the day cell's size is being incorrectly calculated.
  • Qt Creator C++ folding region

    Solved
    19
    0 Votes
    19 Posts
    6k Views
    Q
    I agree wiht it. folding region could let codes look neat and organized without having to create more meaningless funtions and files and jump between them. I saw someone use #pragma region RegionName{ #pragma endregion} to fold codes.and enter text "-Wno-unknow-pragmas" in Tools->Options->C++->Code Model->Build-system warings(Paul)-> Build-system warnings->Copy->(give the configuration name)->(Choose your configuration)->(tick) Use diagnostic flags from build system, to avoid generating warnings.
  • QTreeView item expansion

    Unsolved
    4
    0 Votes
    4 Posts
    5k Views
    L
    @aatwo Did you receive a solution?
  • Qt 6 incompatible with Clang?

    Solved
    5
    0 Votes
    5 Posts
    872 Views
    W
    @Christian-Ehrlicher Yes, it turns out the fix is simple: clang -std=c++17
  • authenticationRequired signal not emited or slot not called

    Unsolved authentication rest server php
    9
    0 Votes
    9 Posts
    3k Views
    D
    @JonB I also thought it could be due to cache, so I ran the manager.clearConnectionCache command but that does not help. I also tried to find a way to force it to provide credentials but I have not found any other way to do so. But that was when I still wasn't sure that the server actually requests this, but since I now know that the server sends the www-authenticate request I know the error is in my applicaton or in qt. Yes, I get the QNetworkReply::AuthenticationRequiredError. So weird that I get that error and not the authenticationRequired signal.
  • 0 Votes
    7 Posts
    1k Views
    l3u_L
    Yeah, okay, I think I got it now. Simply never connect to a lambda as such, but always provide an object that will receive the signal. Otherwise, the catched this may already have been deleted, thus causing a segfault. However, my intial question still remains: Is the approach posted above the correct way to update spans and resize columns of a QTableView?
  • QTabWidget: How to get header widget, which contain tab bar and corner widget?

    Unsolved
    5
    0 Votes
    5 Posts
    560 Views
    S
    @Pl45m4 said in QTabWidget: How to get header widget, which contain tab bar and corner widget?: It either belongs to QTabBar (you can have many tabs there) or it's the background of QTabWidget Implementation hint: override mouseMoveEvent to handle dragging the widget (first checking if you are between the tabs and the corner widgets and checking if the left button is pressed).
  • Fortran and C++ Linking in Qt Creator

    Solved
    5
    0 Votes
    5 Posts
    970 Views
    S
    I'd like to add something to Fortran/C interoperability. Names of Fortran functions are different on different platforms (and you have to know the rules). Fortunately, there is a standard way to define the names in Fortran: ! sum.f90 integer function addup (b, c) bind(c, name="addup") use iso_c_binding implicit none integer(kind=c_int), value, intent(in) :: b integer(kind=c_int), value, intent(in) :: c addup = b + c return end function addup ! I like to be more specific in this place -> sometimes catches bugs // fortranlink.h extern "C" { int addup(int,int); } The important part is use iso_c_binding which allows to add the bind(c). The name specifies the function name as it can be found by the C linker. The advantage is that now in C you can also use the name addup and it is the same on all operating systems. I changed a few more things that make it a little nicer in C or are just modern Fortran. Writing integer :: b is just the modern syntax (I am not sure if it is absolutely required for the other additions I did). integer*4 would also be written better as integer(kind=4). In the context of interoperability with C, I chose kind=c_int (c_int is imported from the iso_c_binding module). At least with the Intel Fortran compiler the default width of integers can be specified as compiler flag and thus does not have to be the same for Fortran and C. Therefore it is better to specify c_int. Or you could use integer(kind=4)/integer*4 in Fortran and int32_t in C/C++ to make them match explicitly. It is also now common to specify the intent of the function parameters: in (i.e. read-only), out (i.e. write-only), and inout. Since you are only reading the values, I specified value as well. Now, you are passing parameters by value instead of by reference (the technical term for the pointers in this context). In this case it makes it much easier to use in C. These are all suggestions, but they can help. If you want use the same functions (addup in your case) in Fortran as well, the easiest option is to introduce modules: module sum use iso_c_binding implicit none contains integer function addup (b, c) bind(c, name="addup") use iso_c_binding implicit none integer(kind=c_int), value, intent(in) :: b integer(kind=c_int), value, intent(in) :: c addup = b + c return end function addup end module sum To use this in other Fortran functions just add use sum (has to be place even before implicit none inside the functions/subroutines). It is a little annoying that you need dependencies to the modules which is a little cumbersome with current build systems (I don't know how qmake would handle this). For small projects it is still reasonable to add the dependencies to modules by hand. (CMake will properly solve this problem because of C++ modules. It is basically the same dependency problem.) We also use modules to put C functions into Fortran: module cpp_bridge use iso_c_binding implicit none interface subroutine foo(x), bind(c, name="foo") integer(kind=c_int),value,intent(in) :: x end subroutine foo ! more subroutines/functions end interface end module cpp_bridge It is nice to have the exact same function names both in C and Fortran. In this way you can use any C function in Fortran as you can now have pass-by-value. PS: I showed you some modern Fortran. Don't overdo it with modern Fortran. For example, using object oriented programming in Fortran will slow things down (up to a factor of 100). In contrast to C++, Fortran does not have the zero-overhead principle (the only zero-cost is not using some modern features). You only need to learn some modern Fortran: the few features I have showed plus maybe pointers and allocatables (yes, you can allocate in modern Fortran). Haven't had a need to use any other modern Fortran features.
  • Application crashing with error in QtCore files

    Unsolved
    4
    0 Votes
    4 Posts
    330 Views
    jsulmJ
    @indo-soft Please post the stack trace after crash. Somewhere in the code a list index is out of bounds of the list.
  • Extend UI to Title bar: How to have UI like Figma application?

    Unsolved qtabbar qtabwidget title bar
    4
    0 Votes
    4 Posts
    735 Views
    H
    I find this docs in Microsoft, but they use C#. I don't know If Qt can do the same as them? Microsoft Title bar [image: 44f63fcb-189e-4584-9636-fe82e76b82b1.png]
  • Problems about a connection to a tcp server with domain!!

    Unsolved
    5
    0 Votes
    5 Posts
    429 Views
    C
    @Pl45m4 Sorry for reply late,here is the code #include "dnsparsetask.h" #include <QHostInfo> namespace Communication { DnsParseTask::DnsParseTask(QObject *parent) : QObject(parent) { } DnsParseTask *DnsParseTask::instance() { static QMutex mutex; static QScopedPointer<DnsParseTask> inst; QMutexLocker locker(&mutex); if (Q_UNLIKELY(!inst)) { if (!inst) { inst.reset(new DnsParseTask); } } return inst.data(); } void DnsParseTask::init(QString hostname,int port,int period) { _self = new QThread(); if(_self == nullptr){ qWarning() << "create thread failed"; return; } _hostname = hostname; _port = port; _periodTime = period; this->moveToThread(_self); connect(_self, &QThread::finished, _self, &QObject::deleteLater); connect(_self, &QThread::finished, this, &QObject::deleteLater); connect(_self, SIGNAL(started()), this, SLOT(startRun())); _self->start(); return; } int DnsParseTask::setDomainToParse(QString domain) { QMutexLocker locker(&_lock); if(domain.isEmpty()){ return -1; } if(_domainMap.contains(domain)){ qWarning() << "domain[" << domain << "] has been in map"; return 0; } _domainMap.insert(domain,""); if(_parseTimer->isActive() == false){ qWarning() << "start parse domain"; _parseTimer->start(); } return 0; } QString DnsParseTask::getDomainIpAddr(QString domain) { if(_domainMap.contains(domain) == false){ return QString(); } return _domainMap.value(domain); } void DnsParseTask::periodicParse() { QObject *obj = _socket; _socket->connectToHost(_hostname,_port); if(_socket->waitForConnected(5000)){ qWarning() << this->thread()->currentThreadId() << ",[connect to host" << _hostname << "] success!";; _parseTimer->stop(); return; } qWarning() << this->thread()->currentThreadId() << ",[connect to host" << _hostname << "] failed:" << _socket->errorString(); return; #if 0 QStringList hostNames = _domainMap.keys(); foreach (const QString &hostName, hostNames) { qWarning() << ">>>>>>>>>>>>>>>:" << this->thread()->currentThreadId() << "," << hostName; QHostInfo hostInfo = QHostInfo::fromName(hostName); if (hostInfo.error() == QHostInfo::NoError) { QList<QHostAddress> addresses = hostInfo.addresses(); foreach (const QHostAddress &address, addresses) { qDebug() << "Resolved IP address:" << address.toString(); } } else { qDebug() << "DNS lookup failed:" << hostInfo.errorString(); } } return; #endif #if 0 QStringList hostNames = _domainMap.keys(); foreach (const QString &hostName, hostNames) { QHostInfo::lookupHost(hostName, [hostName](const QHostInfo &hostInfo) { if (hostInfo.error() == QHostInfo::NoError) { QList<QHostAddress> addresses = hostInfo.addresses(); foreach (const QHostAddress &address, addresses) { qDebug() << "Resolved IP address for" << hostName << ":" << address.toString(); } } else { qDebug() << "DNS lookup failed for" << hostName << ":" << hostInfo.errorString(); } }); } #endif } void DnsParseTask::startRun() { qWarning() << this->thread()->currentThreadId() << "start run period time:" << _periodTime; _domainMap.clear(); _parseTimer = new QTimer(this); connect(_parseTimer,SIGNAL(timeout()),this,SLOT(periodicParse())); _parseTimer->setInterval(_periodTime); _parseTimer->start(); _socket = new QTcpSocket(this); } } And the main function like: int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); DnsParseTask *task = nullptr; task = new DnsParseTask; task->init("mqtts.lfzk.com",1883,500); task = new DnsParseTask; task->init("mqtt.lfzk.com",1883,500); task = new DnsParseTask; task->init("101.200.183.188",1883,100); task = new DnsParseTask; task->init("cb05b435-ba2e-41de-bec9-b9ef2254a1a5.mock.pstmn.io",80,0); a.exec(); return 0; } In the code I create four QTcpSocket and try connect to some domains,the "init" function hold three params,the domain,the port and retry connection interval,and the "periodicParse" function try connect to the domain.On my borad, I use wired netcard "eth0" to connect to servers,”eth0“ configed as dhcp. Before startup the program,I shutdown the netcard by “ifdown eth0”,and then startup the program.The program works 1 minute and print ”Host not found“ error,then I open the netcard ,and my board got correct IP address,but the program still print ”Host not found“ error.I use the cmd "ping -i eth0 mqtts.lfzk.com" ,the cmd works well,I am really confused about this
  • QSLite in memory shared cache, create file on disk

    Solved
    6
    0 Votes
    6 Posts
    646 Views
    C
    @achard-ju said in QSLite in memory shared cache, create file on disk: a file is created on disk in the working directory of my application First. Be very sure that you know where the process' current working directory is. It may not be where you think it is. Second. Try opening the in-memory database as described here. This appears to be introduced in Sqlite 3.7.13. A lot has changed between Qt 4 and Qt 5. A lot has changed in Sqlite over the decade between 2011-09-19 and 2021-01-20, which are the release dates of the two versions concerned. At least versions 3.14, 3.8.8, 3.8.7.3, 3.7.17, 3.7.15, and 3.7.13 have touched shared cache mode (and in some cases fix corruption bugs).
  • Catch seg fault from DLL linked to EXE

    Solved
    2
    0 Votes
    2 Posts
    197 Views
    C
    @Ali-Goodarz said in Catch seg fault from DLL linked to EXE: I know the best course of action is solving the bugs in the dll, and we do that, but I also don't want any unsolved seg faults to crash our main application. I do not think you can safely do this. Whatever failed in the DLL has left your program in an unknown state. It is hard to recover and keep running if you do not know where you are starting from. I suspect that the best you could hope for is that data already written to disk is flushed before you let the main program die. What would be the best way of doing this? Structured Exception Handling might provide some options, including SetUnhandledExceptionFilter().
  • Reading in video files?

    Solved
    7
    0 Votes
    7 Posts
    524 Views
    W
    @whatabout I just use a CMake build system in my own project. I haven't bothered keeping it particularly up to date or anything, but feel free to grab my CMake as a starting point if it's useful: https://github.com/wrosecrans/ffms2/blob/master/CMakeLists.txt May need some tweaks to keep up with upstream. I link it to an ffmpeg from vcpkg.
  • hover stylesheet works for Linux but fails for Windows

    Unsolved
    1
    0 Votes
    1 Posts
    145 Views
    No one has replied
  • Has QNetworkAccessManager gone obsolete for 5.15.15?

    Unsolved
    3
    0 Votes
    3 Posts
    688 Views
    SGaistS
    Hi and welcome to devnet, Beside the good suggestion of @Christian-Ehrlicher and based on the answer of the linked thread, did you had an update done to your Windows machine ? Did you try to run your application on a different Windows version ?
  • make QT application response to API calls

    Unsolved
    4
    0 Votes
    4 Posts
    894 Views
    Z
    @ChrisW67 Thank you! no I dont need to do any binding with .net, I just mentioned .Net web api controller to give an example of what I want to do but in QT
  • QVariant::save: unable to save type

    Solved
    3
    0 Votes
    3 Posts
    971 Views
    Pl45m4P
    @Redman Change to qRegisterMetaType<QList<MyClass>>(); if you want a metaType QList of MyClass items.
  • Rotating QRect using QTransform and Cropping a QImage with it

    Solved
    8
    0 Votes
    8 Posts
    1k Views
    S
    @SimonSchroeder so rotating the painter itself and later cropping, yes i think it was suggested as well. and yes that seems to work for now. will be marking this solved.
  • Segmentation fault on every project since this morning (windows 10)

    Unsolved
    5
    0 Votes
    5 Posts
    1k Views
    jsulmJ
    @monegator said in Segmentation fault on every project since this morning (windows 10): i'm bound to use whatever dell makes available for my laptop You should be able to install Intel drivers from Intel site on Dell machines (was working for me just fine in the past).