Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.8k Posts
  • Qtabwidget addtab duplicates tab on second click

    Solved
    3
    0 Votes
    3 Posts
    456 Views
    U
    Christian Ehrlicher, Thanks. Removing the "else if" and returning "true" in the control_tab() fixed.
  • This topic is deleted!

    Unsolved
    3
    0 Votes
    3 Posts
    3 Views
  • Gherkin syntax highlighting in Qt Creator. How?

    Solved
    4
    0 Votes
    4 Posts
    398 Views
    B
    @JKSH thanks. Will do it by my own. Issue closed.
  • Compile for linux target from windows.

    Unsolved cross compile linux gcc
    2
    0 Votes
    2 Posts
    2k Views
    K
    @Lior Hi and welcome to devnet forum Do you have a cross-compiler for cross-compilation on windows for linux? There are certainly cross-compilers available. You would have to cross-compile Qt libs with that cross-compiler. After this you can use the cross-compile toolchain and do a cross-compilation for your applications. My personal recommendation is to use virtual machine e.g. VirtualBox and setup the linux environment. Use Qt creator on linux and on windows. You will have the same look and feel in both environments. That is how I do my developments. All is done on windows. However, targeting linux desktop and embedded linux I do the compilation on linux desktop. The reason is lesser pain.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    16 Views
    No one has replied
  • Prevent QDialog from hiding

    Solved
    5
    0 Votes
    5 Posts
    507 Views
    krzysieklfcK
    @mrjj I'm using QPropertyAnimation on a windowOpacity property. I shared the code in the answer here. I also added dark overlay effect. [image: 8c643521-ae4b-4f8e-bc80-24600a6ce383.gif]
  • Is Qt beginner friendly?

    Unsolved
    5
    0 Votes
    5 Posts
    610 Views
    aha_1980A
    Hi @Ktns I went to take a look at Qt products and something confused me, which product allows me to drag and drop stuff into my UI? is it Qt creator or Qt Design? I can't tell the difference Qt Designer is the tool to drag'n'drop UIs. It is embedded into Qt Creator (which is a full-featured IDE), though. So you can either use it from Creator (which I would recommend) or standalone, just how you like. Regards
  • Cannot get data from HTTP request

    Unsolved
    22
    0 Votes
    22 Posts
    3k Views
    T
    Changed it like: connect( manager, &QNetworkAccessManager::finished, this, &Manager::replyFinished ); connect( manager, &QNetworkAccessManager::sslErrors, this, &Manager::replyFinished ); QNetworkReply *reply = manager->get(request); and still doesn't work, no error, no reply.
  • QCombo selected item background colour

    Unsolved
    11
    0 Votes
    11 Posts
    2k Views
    B
    @JonB said in QCombo selected item background colour: @mrjj His specification is I can set the background colour of an item. However, when this item is selected, the background changes some mid-gray. Once another item is selected, the background colour returns to the one I set. I don't want to set the selected-item colour but want to display the pre-set colour even if it is selected. He wants the background colour --- which he has already changed to his liking on non-selected items --- to stay as it was when an item is selected, rather than (at present) where it changes to some other color. He has said nothing other than that about "highlighting", so e.g. if selecting changes the foreground color or boldness (I don't know if it does) we don't care, it's the background color which matters. :) Thanks for the reply, spot on! [Could have gotten it done by now by just using stylesheet ;-) ] Could have if i just knew WHAT to actually type in ... if you'd like to quickly type it out ...? What I checked is: https://doc-snapshots.qt.io/qt5-dev/stylesheet-examples.html#customizing-qcombobox It has some haphazard examples, none seem to be relevant. Back to the core documentation: https://doc-snapshots.qt.io/qt5-dev/stylesheet-reference.html#list-of-properties where it says about 1/4 way down the page:" List of Properties The table below lists all the properties supported by Qt Style Sheets. " Here I found a relevant property: selection-background-color Which says "The background of selected text or items." Except that it does not. It temporarily changes the background color of the item the mouse is over. Another relevant property is : background. It says "Shorthand notation for setting the background. Equivalent to specifying background-color" Except that not entirely. It does change the BG colour but it also changes the 'highlight' colour to the same. Highlight=the temporary change of the item's BG colour while the mouse is over it. To overcome this problem, the highligt-BG-color must be reset too every time. Highlight-BG-colour here means : selection-background-color. See code below. I am still wondering, how can the 'selection-background-color' retrieved from the stylesheet-mess. Reading: https://doc.qt.io/qt-5/qt.html about 2/3 down says: "Roles describing appearance and meta data (with associated types):" In the following list i couldn't find any relevant role to get the current 'selection-background-color'. Also, so far I couldn't find anything on google. If you feel that i am totally lost and just about randomly shooting in the dark: you are not wrong. That is exactly what i feel. If someone could give a more intelligent code, it would be appreciated. This is the code that almost works: (For clarity's sake, irrelevant code is omitted) some-function() { QStringList comboitems; comboitems << "Item 1" << "Item 2" << "Item 3"; ui->comboBox->addItems(comboitems); ui->comboBox->setItemData(0,QColor(Qt::blue),Qt::BackgroundRole); ui->comboBox->setItemData(1,QColor(Qt::red),Qt::BackgroundRole); ui->comboBox->setItemData(2,QColor(Qt::yellow),Qt::BackgroundRole); } void MainWindow::on_comboBox_activated(int index) { /*one can't simply currentStyle = combo.getStylesheet because these are cascading and the object only knows about the result. It is unable to return the source. It can return the stylesheet if you set one. Welcome to the beauty of the styleshit. */ //get the current BG colour QVariant var = (ui->comboBox->itemData(index, Qt::BackgroundRole)); //convert to QColor QColor mycolor = var.value<QColor>(); //there is no built-in function to convert QColor to a string ... but the styleshit needs a string int red = mycolor.red(); int green = mycolor.green(); int blue = mycolor.blue(); QString strRGB = "rgb(" + QString::number(red) + "," + QString::number(green)+ "," + QString::number(blue) + ")"; qDebug() << "strRGB: " << strRGB; //the current selection-beckground-color shoud be retrieved but i have no idea how to do this. Thus it is hard-coded. //... and FINALLY! //Set the BG colour AND reset the selection-highlight colour ui->comboBox->setStyleSheet("background:" + strRGB + "; selection-background-color: yellow;"); }
  • 0 Votes
    11 Posts
    3k Views
    SGaistS
    A library is not an application. If you are targeting several Linux distributions, the nicest would be to provide a package using their format e.g. .deb files for Debian based distributions. As for Windows, there's no real package format. Maybe using something like conan.io might be an option. Otherwise an archive that provides your .dll, header and .lib files for the various compilers you want to support is usually good enough. However packing a full version of all your dependencies, while it sounds nice, might prove problematic. If you provide them, then you should also take care of updating them in case of security issues found during the year.
  • Yet another QProcess write issue

    Unsolved
    12
    0 Votes
    12 Posts
    2k Views
    M
    @JonB Got it. Thanks very much for the time spent to make things more clear!
  • Ui or MainWindow has not been declared

    Solved
    3
    0 Votes
    3 Posts
    983 Views
    B
    @mrjj Thanks, it works.
  • iOS 13 SSL ca certificate untrusted (self signed)

    Solved
    3
    0 Votes
    3 Posts
    1k Views
    Pablo J. RoginaP
    @Morfio said in iOS 13 SSL ca certificate untrusted (self signed): it works perfectly, so mark your post as solved please! Thanks.
  • How to create or show the toolbar for Creator?

    Unsolved
    2
    0 Votes
    2 Posts
    211 Views
    mrjjM
    Hi and welcome to the forums When you are in a .h or cpp file you can save from main file menu [image: DG04qG.png] or in the menu on top of the file [image: DEiHEm.png] but there is no toolbar button, i have seen.
  • JS name of Global Object

    Unsolved
    1
    0 Votes
    1 Posts
    135 Views
    No one has replied
  • QPalette.HighlightedText not returning accurate value?

    Unsolved
    2
    0 Votes
    2 Posts
    320 Views
    mrjjM
    Hi Nope, you are not doing anything wrong. :) It seems to depend a bit on the Widget in Question, the QStyle used and platform if the palette is used for the actual drawing. So more often stylesheets work better. When i want to use palette, i normally test it first QPalette p = ui->listWidget->palette(); for (int cr = QPalette::ColorRole::WindowText; cr < QPalette::ColorRole::PlaceholderText; ++cr) { p.setColor( QPalette::ColorRole(cr), Qt::red); } ui->listWidget->setPalette(p); This changes all colors so its easy to see if it will work. ( on that platform) so here on ListWidget ( windows platform) does seems to use it [image: w4LlNk.png] However, i can also see some effect is added to the selected drawing. as else it would not be visisble. Also as a note. you are taking the system palette. Also test the Widgets one (just to be sure) SELECTED_TEXT_COLOR = w.palette.color(QPalette.HighlightedText)
  • How can I get the default gateway IP using QT ?

    16
    0 Votes
    16 Posts
    18k Views
    mrjjM
    @Taytoo well it used to work on Debian so high chance it will work on Ubuntu too but time moved on and changes might be needed. I have no idea about macOs but my guess would be no. also the last post using CoInitializeSecurity seems very windows focused.
  • How do I remove previous paint and repaint in QGraphicsItem?

    Unsolved
    7
    0 Votes
    7 Posts
    2k Views
    Christian EhrlicherC
    Then please mark the issue as solved, thx.
  • 'void QTimer::timeout()' is protected

    Solved
    6
    0 Votes
    6 Posts
    1k Views
    mrjjM
    @Mijaz Good luck with the porting. Just as a note. You did see the guides ? https://wiki.qt.io/Transition_from_Qt_4.x_to_Qt5 https://doc.qt.io/qt-5/portingguide.html https://www.kdab.com/porting-from-qt-4-to-qt-5/
  • Label data points with vertical text (QChart)

    Solved
    7
    0 Votes
    7 Posts
    3k Views
    D
    Thanks @Pl45m4 I'll try but it might take a while since I am just starting. When I'am done, I will report on my success or failure. Cheers delos