Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.3k Topics 456.0k Posts
  • QPushButton default windows style sheet

    Solved qpushbutton sty stylesheet windows
    12
    0 Votes
    12 Posts
    10k Views
    Chris KawaC
    To remove stylesheet style simply set an empty string i.e. someWidget->setStyleSheet("border: 1px solid red; background-color: blue;"); // sets a stylesheet someWidget->setStyleSheet({}); // removes a stylesheet
  • which is better, MinGW64 or MSVC 2019 64bit for general use applications.

    Unsolved
    5
    0 Votes
    5 Posts
    782 Views
    S
    I have personally always been using MSVC on Windows and would always pick this as a compiler. The Visual Studio debugger is a lot better than the one built in to Qt Creator (debugging in Qt Creator can be terribly slow on Windows taking several minutes for just a single step). vc_redist can be a little bit annoying. However, when you are using an installer for your software this can be included as a dependency and will be fine. @Blackzero said in which is better, MinGW64 or MSVC 2019 64bit for general use applications.: if I use open source static it is not possible because my goal is for my own small commercial. This is not entirely true. In order to use open source static you need to compile Qt yourself. This is doable. The LGPL requires for the user to be able to relink with a different Qt version. As long as you are willing to provide your objects files (maybe already linked into a static library) together with an explanation of how to link to static Qt libraries, this is also feasible. Even though the LGPL provides these rights to the user, in general it is highly unlikely that anyone will make use of this right. This might be a risk you are willing to take (i.e. the risk that you never have to effectively provide a way for a user to relink with a different static Qt version because noone will ever make use of this right). (I'm not a lawyer; this is not legal advice.)
  • QComboBox/QStyledItemDelegate, Icon Size for selected item.

    Unsolved
    2
    0 Votes
    2 Posts
    216 Views
    P
    Here's an image of what I'm talking about, seem the spam filter doesn't stop it here. [image: d4ca4419-e1a6-497a-9b0b-a34f5e4c4844.png]
  • how to set responsive on large screen resolutions

    Unsolved
    4
    0 Votes
    4 Posts
    192 Views
    Christian EhrlicherC
    So either upgrade to a recent Qt6 version where high-dpi support is highly improved or try to play around with QT_SCALE_FACTOR and Qt::AA_EnableHighDpiScaling: https://doc.qt.io/qt-5/highdpi.html
  • Qt creator Update text file with input data

    Solved
    14
    0 Votes
    14 Posts
    834 Views
    JonBJ
    @Ruben12313 You (attempt to) "truncate" the file you are writing to as you write each line to it! You have a stream named in3 which is only used for output. If there are no lines now in the widget you fail to truncate/clear out any lines which were in the file (e.g. after deleting). Etc. It makes no sense. I leave it to you.
  • 0 Votes
    7 Posts
    339 Views
    JonBJ
    @Torch said in The application crashes after 3 seconds.I'm writing a task manager in qt with a database,.: Adding task: "Task 1" Error adding task: "Parameter count mismatch" Failed to add Task 1 So don't you think this code needs showing?
  • Frameless widget shakes during resizing

    Unsolved qt6 resize frameless c++
    3
    0 Votes
    3 Posts
    723 Views
    D
    I have the same problem, looking for someone to answer it.
  • 0 Votes
    2 Posts
    123 Views
    Axel SpoerlA
    Hi, that's a known issue, related to the touch screen driver for Windows. Not related to Qt.
  • How to fix inconsistent window placement?

    Solved
    3
    0 Votes
    3 Posts
    180 Views
    D
    @mpergand using size() would discard the height of the bottom dock and place the window behind it. However I found the solution to correctly calculate the position by using availableVirtualGeometry(). The returned QRect does take into account the top menu bar height and the calculation basically is now as follows: const auto geom = logWindow->screen()->availableVirtualGeometry(); //qDebug() << "avail virtual geo: " << logWindow->screen()->availableVirtualGeometry(); logWindow->resize(static_cast<int>(std::round(geom.width() * 0.75)), 240); logWindow->show(); logWindow->move(0, geom.height() + geom.y() - logWindow->frameGeometry().height()); This does work on both platforms.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    14 Views
    No one has replied
  • multiple plot management environment in pyqt

    Unsolved
    2
    0 Votes
    2 Posts
    144 Views
    SGaistS
    Hi, AFAIK, there's no "complete" plot handling pre-made widget. You can likely achieve what you want using Qwt. KDE's Labplot might be of help on your endeavor.
  • How to add a row to a subclass of QAbstractTableModel?

    Unsolved table view table model
    5
    0 Votes
    5 Posts
    638 Views
    Pl45m4P
    @Pl45m4 said in How to add a row to a subclass of QAbstractTableModel?: For more detail check out the Editable TreeView Example (it's TreeView but in general the insert/remove procedure of rows and cols is the same) https://doc.qt.io/qt-6/qtwidgets-itemviews-editabletreemodel-example.html @jdent see here
  • Manipulating characters within a QTextDocument/QAbstractTextDocumentLayout

    Unsolved
    4
    0 Votes
    4 Posts
    391 Views
    H
    In this book, there is explanation to subclass QAbstractTextDocumentLayout. https://www.amazon.co.jp/dp/B0D5BXJQBX?&linkCode=ll1&tag=multilinger19-22&linkId=6f566cae61fec736270f5086292ea57c&language=ja_JP&ref_=as_li_ss_tl
  • Is there a risk of crashing in the QImage::setColorSpace method?

    Unsolved qt6 qt5
    6
    0 Votes
    6 Posts
    664 Views
    Christian EhrlicherC
    The check in setColor() is not needed - if there is an oom the app will crash.
  • Unable to successfully import files with mix use of PySide6 and PyQt6

    Unsolved
    22
    0 Votes
    22 Posts
    3k Views
    JonBJ
    @explorer100 Somebody, somewhere did write some sort of Python upgrade script to find and replace all the occurrences of the old symbols with the new ones. I don't know how good it is, but maybe it comes with a list of those which need changing you can look through. I know I have referred to it in my posts here, but that was a long time ago. Whether I can find it again I don't know.... Oh, it's at https://stackoverflow.com/questions/72086632/migrating-to-qt6-pyqt6-what-are-all-the-deprecated-short-form-names-in-qt5. For PyQt5->6. There's a script to copy or a Py package to fetch. Or there's https://github.com/qutebrowser/qutebrowser/issues/5904#issuecomment-736792450. It seems they look through files supplied with PyQt rather than having a hard-coded list you could look at.
  • How to use an Object of type QSqlTableModel in another function of the same class?

    Unsolved
    21
    0 Votes
    21 Posts
    2k Views
    SGaistS
    @mooswitz sorry, that was a bad suggestion, you would lose the error handling check.
  • 0 Votes
    21 Posts
    3k Views
    SGaistS
    @Bonnie I have not factored that into account but in the absolute, if not provided by the installer I would go get the official libraries.
  • 0 Votes
    5 Posts
    312 Views
    M
    Thank you both for the feedback/ideas. I suspect I may be doing stuff completely wrong here from a design point of view, which might be why styling doesn't seem to work. @Pl45m4, you are mentioning widgets and styling widgets, and I'm a bit lost as to which widgets I am trying to stylize. I have list of items that I want to display that is 1k+ items. The list needs a custom widget, as each item has 3 buttons that perform actions on that item. Something like this: [image: a92dc886-178c-4cfe-beba-f09eaf66713c.png] I first tried using a normal QListWidget where each gets a setItemWidget with a custom widget that contains the item label and buttons. This worked great, and inherited all of the styling from the theme/style that is loaded into the app (e.g.- a nice blue background for hover, darker blue for select, a nice rounded corner for the selected/hovered list items, etc..). However once the number of items in the list exceeded a couple hundred, it became extremely slow to load. Thus I moved to using a QListView and a custom QStyledItemDelegate to draw the items. This QStyledItemDelegate implements a paint method, and draws out a text box, button boxes, etc: void QuickAccessSourceDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { const auto model = static_cast<const QuickAccessSourceModel*>(index.model()); auto item = model->item(index.row()); std::string mode = obs_frontend_is_theme_dark() ? "theme:Dark/" : "theme:Light/"; QString text = item->getName().c_str(); QRect rect = option.rect; if(option.state & QStyle::State_Selected) painter->fillRect(option.rect, option.palette.highlight()); if (option.state & QStyle::State_MouseOver) painter->fillRect(option.rect, option.palette.accent()); QRect textRect(rect); textRect.setWidth(rect.width() - 107); textRect.setHeight(30); textRect.setX(32); painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, text); int loc = START_LOC; int inc = INC; if (_dock->ShowScenes()) { QRect ParentScenesButtonRect(rect); ParentScenesButtonRect.setX(rect.width() - loc); ParentScenesButtonRect.setHeight(30); ParentScenesButtonRect.setWidth(30); QStyleOptionButton parentScenesButton; parentScenesButton.rect = ParentScenesButtonRect; QIcon scenesIcon; std::string scenesIconPath = mode + "sources/scene.svg"; scenesIcon.addFile(scenesIconPath.c_str(), QSize(), QIcon::Normal, QIcon::Off); parentScenesButton.icon = scenesIcon; parentScenesButton.iconSize = QSize(16, 16); parentScenesButton.state = _filtersState | QStyle::State_Enabled; style->drawControl(QStyle::CE_PushButtonLabel, &parentScenesButton, painter, widget); loc += inc; } if (_dock->ShowFilters()) { // Same as ShowScenes Above loc += inc; } if (_dock->ShowProperties() && item->hasProperties()) { // Same as ShowScenes Above loc += inc; } textRect.setWidth(rect.width() - (loc + 2)); } It then has a an editorEvent implemented that takes care of the button presses. Is the fact that I am using primitives in a paint function part of why theming wont work? Is there a way to use standard widgets in my StyledItemDelegate rather than using all primitives in a paint function? Is there a better way to do this? One thing I've noticed- the fillRect I am calling to fill the background rectangle if hovered/selected works, however the color it is grabbing seems to be the default QT6 colors, not the stylesheet colors that are loaded for a QListWidget:item in the app.
  • QTableWidget elide middle not working as expected

    Solved qtablewidget elide mode
    2
    0 Votes
    2 Posts
    468 Views
    Christian EhrlicherC
    I would guess your QTableWidgetItem has wordWrap set to true (default). This works fine for me: int main(int argc, char** argv) { QApplication app(argc, argv); QTableWidget tw; tw.setRowCount(1); tw.setColumnCount(1); auto item = new QTableWidgetItem("a very long text which is elided in the middle"); tw.setItem(0, 0, item); tw.setTextElideMode(Qt::ElideMiddle); tw.setWordWrap(false); tw.show(); }
  • (Cross-)Compiler Qt6.8 for Ubuntu and Raspberry Pi

    Solved
    3
    0 Votes
    3 Posts
    803 Views
    M
    Thank you. I installed gcc-11 and g++-11 and it worked.